Table of Contents

MovieClip.duplicateMovieClip( ) Method Flash 6

create a copy of a movie clipFlash 5; initObject and return value added in
mc.duplicateMovieClip(newName, depth)
mc.duplicateMovieClip(newName, depth, initObject)

Arguments

newName

A string that will become the instance name of the duplicated clip. The name must adhere to the rules for creating an identifier outlined under Section 15.5.

depth

An integer between -16384 and 1048575 (inclusive), specifying the level on which to place the new clip inside mc's parent. Higher depths obscure lower depths, so a depth of 6 is in front of 5, which is in front of 4, and so on. Depths above -1 are reserved for dynamically generated content. Therefore, in most cases, you should use a depth between 0 and 1048575 with duplicateMovieClip( ). However, when creating dynamic content that you want to appear beneath all author-time content in mc (e.g., a runtime background), use depth -16384. Depths from -16383 to -1 (inclusive) are reserved for author-time content and shouldn't be used with duplicateMovieClip( ). For important details, see Section 13.4.

initObject

An optional object whose properties are copied to the new movie clip instance. Not supported in Flash 5.

Returns

In Flash 6, duplicateMovieClip( ) returns an object reference to the attached movie clip (in Flash 5, it always returns undefined).

Description

The MovieClip.duplicateMovieClip( ) method is an alternative to the global duplicateMovieClip( ) function. When invoked as a MovieClip method, duplicateMovieClip( ) takes no target parameter (as it does with the global version)—it duplicates mc and returns a reference to the new duplicate. The MovieClip method syntax is less prone to user error than its global function counterpart because no target parameter is required.

For general usage instructions, see the global duplicateMovieClip( ) function. For details on the initObject parameter, see MovieClip.attachMovie( ) and Chapter 14.

Usage

The global form of duplicateMovieClip( ) does not include support for the initObject parameter, nor does it return a reference to the newly duplicated clip (these limitations also apply to the movie clip method form in Flash 5).

Example

Make a duplicate of ball1_mc named ball2_mc. The duplicate is placed on depth 1 inside ball1_mc's parent:

ball1_mc.duplicateMovieClip("ball2_mc", 1);

See Also

duplicateMovieClip( ), MovieClip.attachMovie( )


Table of Contents