View comments | RSS feed

MovieClip.getInstanceAtDepth()

Availability

Flash Player 7.

Usage

my_mc.getInstanceAtDepth(depth:Number) : MovieClip

Parameters

depth An integer that specifies the depth level to query.

Returns

A reference to the MovieClip instance located at the specified depth, or undefined if there is no movie clip at that depth.

Description

Method; lets you determine if a particular depth is already occupied by a movie clip. You can use this method before using MovieClip.attachMovie(), MovieClip.duplicateMovieClip(), or MovieClip.createEmptyMovieClip() to determine if the depth parameter you want to pass to any of these methods already contains a movie clip. For more information, see "Managing movie clip depths" in Using ActionScript in Flash.

You can extend the methods and event handlers of the MovieClip class by creating a subclass. For more information, see "Assigning a class to a movie clip symbol" in Using ActionScript in Flash.

Example

The following example displays the depth occupied by the logo_mc movie clip instance in the Output panel:

this.createEmptyMovieClip("logo_mc", 1);
logo_mc.loadMovie("http://www.macromedia.com/devnet/blueprint/articles/nielsen/spotlight_jnielsen.jpg");
trace(this.getInstanceAtDepth(1)); // output: _level0.logo_mc

See also

MovieClip.getDepth(), MovieClip.getNextHighestDepth(), MovieClip.swapDepths()

Comments


silverfh said on Jan 4, 2005 at 2:37 PM :
is there any way that i can get all the instances in a movieclip...?

lets sat I have a movie "mc" on root.. and in it i have 3 movies with 3 instances.. now can i somehow trace those instance if i dont know them ? or if i dont know how much movies are in a movie.. or how much instance are in a movie clip.. then can i get them on the fly ?
Francis Cheng said on Jan 7, 2005 at 12:08 PM :
You can use a for..in loop to iterate through the instances that a movie clip contains:
http://livedocs.macromedia.com/flash/mx2004/main_7_2/00001351.html
If you need further assistance, your best bet is to post a detailed query in the web forums:
http://webforums.macromedia.com/flash

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001506.html