User Guide

Table Of Contents
duplicateMovieClip() 13
Operands
target The target path of the movie clip to duplicate.
newname A unique identifier for the duplicated movie clip.
depth A unique depth level for the duplicated movie clip. The depth level indicates a
stacking order for duplicated movie clips. This stacking order is much like the stacking order
of layers in the timeline; movie clips with a lower depth level are hidden under clips that have
a higher depth level. You must assign to each duplicated movie clip a unique depth level so
that it does not overwrite existing movie clips on occupied depth levels.
Description
Function; creates an instance of a movie clip while the SWF file plays and returns a reference
to the duplicated movie clip. The playhead in a duplicate movie clip always starts at Frame 1,
regardless of where the playhead is in the original (parent) movie clip. Variables in the parent
movie clip are not copied into the duplicate movie clip. If the parent movie clip is deleted, the
duplicate movie clip is also deleted. Use the
removeMovieClip() function or method to
delete a movie clip instance created with
duplicateMovieClip().
Example
The following example duplicates a movie clip named originalClip to create a new clip
named
newClip, at a depth level of 10. The new clips x position is set to 100 pixels.
duplicateMovieClip("originalClip", "newClip", 10);
setProperty("newClip", _x, 100);
The following example uses duplicateMovieClip() in a for loop to create several new
movie clips at once. An index variable keeps track of the highest occupied stacking depth.
Each duplicate movie clips name contains a numeric suffix that corresponds to its stacking
depth (
clip1, clip2, clip3).
for (i = 1; i <= 3; i++) {
newName = "clip" add i;
duplicateMovieClip("originalClip", newName); }
See also
removeMovieClip()