This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
Written by: Evgueni Strok Difficulty Level: Beginner Requirements: Flash 5 or higher duplicatemovieclip creates a copy of a movie clip specified using an instance name.
I think the best way to understand how it works is to start from a very basic example and step by step we'll try to add some new lines of code.
EXAMPLE 1
To duplicatemovieclip we need a Movie Clip (MC) which will be duplicated. In my example I made a MC_1 with Instance name "box"
I'll call a duplicatemovieclip function by using button with this script on it:
The duplicated MC inherits the _x and _y coordinates of the clip it is copied from, so it will appear above the original but we can move this using a setProperty action. See example below.
This example duplicates an MC 20 times using a while loop. See the Scripted Loops tutorial for more on loops, and the Advanced Pathing tutorial for more on the strange paths used in this example.
The next example duplicates an MC 20 times and uses "random" properties for each duplicated MC. Thus each new MC will get a random _x, _y, _xscale, _xscale positions and _alpha properly.
Note: If you reuse the same Instance name for duplicated MC you'll replace the old one. The above code creates a new unique instance name each time using a counter.
EXAMPLE 5
This example has the same actionscript which has been added on frame. And a MC has a small timeline.