Toxiclab.org

Duplicate object using the action script code

12.12.2007, 16:52
Submited in: Flash | Total Views: 31434

In this tutorial, you will see how to duplicate any object using the action script code. Let's go!



Step 1

Open a new flash document.



Step 2


Draw, or Import any object into a flash, which you like to duplicate on click. For this example I have typed "toxiclab.org".

Step 3

While the object is still selected, press F8 key (Convert to Symbol) to convert this object into a Movie Clip Symbol.



Step 4

While the new made Movie Clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip object. See the picture below.



Step 5

Take the Selection Tool (V) and click once on the new made Movie Clip to select it. After that, go to the Action Script Panel (F9) and enter this code inside the actions panel:

onClipEvent (load) {
 scale = (random(100) + 50)

 this._x = random(300);
 this._y = random(200);
 this._xscale = scale;
 this._yscale = scale;
}


Step 6

After that, create a new layer above the layer 1 and name it button.

Step 7

Select the button layer and create some button on the stage. See the picture below.



Step 8

Select that button and go to the action script panel again. Then, enter this code inside the actions panel:

on (press) {
i = i + 1;
duplicateMovieClip (_root.object, "object" + i, i);
}

We're done!

Click once on the button to duplicate your object.

Have a nice day!

Download example

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category


Most popular tutorials