duplicateMovieClip()
531
duplicateMovieClip()
Availability
Flash Player 4.
Usage
duplicateMovieClip(
target:String
,
newname:String
,
depth:Number
)
: Void
Parameters
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 is a stacking order for
duplicated movie clips. This stacking order is similar to the stacking order of layers in the
Timeline; movie clips with a lower depth level are hidden under clips with a higher stacking order.
You must assign each duplicated movie clip a unique depth level to prevent it from replacing
SWF files on occupied depths.
Returns
Nothing
Description
Function; creates an instance of a movie clip while the SWF file is playing. The playhead in
duplicate movie clips always starts at Frame 1, regardless of where the playhead is in the original
movie clip. Variables in the original movie clip are not copied into the duplicate movie clip. Use
the
removeMovieClip()
function or method to delete a movie clip instance created with
duplicateMovieClip()
.
Example
In the following example, a new movie clip instance is created called
img_mc.
An image is loaded
into the movie clip, and then the
img_mc
clip is duplicated. The duplicated clip is called
newImg_mc
, and this new clip is moved on the Stage so it does not overlap the original clip, and
the same image is loaded into the second clip.
this.createEmptyMovieClip("img_mc", this.getNextHighestDepth());
img_mc.loadMovie("http://www.macromedia.com/images/shared/product_boxes/
112x112/box_studio_112x112.jpg");
duplicateMovieClip(img_mc, "newImg_mc", this.getNextHighestDepth());
newImg_mc._x = 200;
newImg_mc.loadMovie("http://www.macromedia.com/images/shared/product_boxes/
112x112/box_studio_112x112.jpg");
To remove the duplicate movie clip, you could add this code for a button called
myButton_btn
.
this.myButton_btn.onRelease = function(){
removeMovieClip(newImg_mc);
};
See also
MovieClip.duplicateMovieClip()
,
removeMovieClip()
,
MovieClip.removeMovieClip()
CHAPTER 7
ActionScript for Flash
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...