initObject:Object
contains properties with which to populate the duplicated movie clip. This parameter allows
dynamically created movie clips to receive clip parameters. If
is ignored. All properties of
specified with
initObject
Returns
- A reference to the duplicated movie clip (supported for Flash Player 6 and later).
MovieClip
Example
The following example duplicates a newly created MovieClip a number of times and traces
the target for each duplicate.
var container:MovieClip = setUpContainer();
var ln:Number = 10;
var spacer:Number = 1;
var duplicate:MovieClip;
for(var i:Number = 1; i < ln; i++) {
var newY:Number = i * (container._height + spacer);
duplicate = container.duplicateMovieClip("clip-" + i, i, {_y:newY});
trace(duplicate); // _level0.clip-[number]
}
function setUpContainer():MovieClip {
var mc:MovieClip = this.createEmptyMovieClip("container",
this.getNextHighestDepth());
var w:Number = 100;
var h:Number = 20;
mc.beginFill(0x333333);
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.lineTo(0, 0);
mc.endFill();
return mc;
}
The
MovieClip.getNextHighestDepth()
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
See also
loadMovie (MovieClip.loadMovie method)
(MovieClip.removeMovieClip method)
856
ActionScript classes
[optional] - (Supported for Flash Player 6 and later.) An object that
are copied into the new instance. The properties
initObject
are available to the constructor function.
MovieClip.getNextHighestDepth()
,
initObject
method used in this example requires Flash Player
,
removeMovieClip
duplicateMovieClip function
is not an object, it
method.
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?