I have a movie clip who is only a square, i need to copy it on the flash stage a number of times (dinamic). How can i do this in execution time, i know AS2, so i prefer a solution in AS2. Thanks for you help!
Create your MovieClip in the library, right-click it and select "Properties". Check the boxes for "Export for Actionscript" & "Export in Frame 1". Then type a name into the Identifier box, something like: my_square
This will make your MovieClip available for use in Actionscript.
Then, use something like the following AS2 code to attach multiple versions to the stage:
for (i = 0; i < 5; i++)
{
var mc = _root.attachMovie("my_square", "my_square_"+i, i);
mc._x = i * 50;
}
This will create 5 copies of the square, naming them "my_square_0", "my_square_1", etc. It stores a reference to the new MovieClip in the "mc" var, so you can manipulate it further. For example, this code spaces them 50px apart.
In the attachMovie method, the first argument is the Identifier you chose for your MovieClip. The second argument is a unique name for the new copy of it, and the third argument is the depth at which to display it. More info on the attachMovie method here
In AS 2.0 it's also possible to duplicate the Movieclip using duplicateMovieClip
Draw the square on the stage.
Hit F8 to convert it to a movieclip and give it a name
Select it on stage and give it an instance name, for example square
Use:
duplicateMovieClip (square, "square2", this.getNextHighestDepth());