- Open Adobe Flash software, click on “Action Script 3.0” in create new section
- Create a rectangle using “Rectangle Tool”, select it and go to “Convert to symbol” (“F8” key) option under modify menu
- Let the name as “Symbol 1” itself, click on “Export for ActionScript” check box and write the Class as “block” which was “Symbol1” before. Click “OK”, again click “OK” for “Action Script Class” warning dialog box
- Change the instance name of rectangle as “box0” (0 is number)
- Place the following code in frame1
import flash.display.*;
var counter=1;
box0.addEventListener(MouseEvent.CLICK,makeblock);
function makeblock(e:Event){
this[“box“+(counter)]=new block;
this[“box“+(counter)].x=this[“box“+(counter-1)].x;
this[“box“+(counter)].y=this[“box“+(counter-1)].y+this[“box”+(counter-1)].height;
addChild(this[“box”+(counter)]);
counter++;
}
- Test your movie using Ctrl+Enter and click on the rectangle you have created, you can see a new rectangle below.
That’s it. Here we exported the movie clip to action script as a class named “block” and used “addChild” function to add the another instance of movie clip to the stage. We also specified the new instance name to “box” using the “counter” variable.
Here you can get the attached