MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 367

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Determining the next highest available depth
To determine the next highest available depth within a movie clip, use
. The integer value returned by this method indicates
MovieClip.getNextHighestDepth()
the next available depth that will render in front of all other objects in the movie clip.
The following code attaches a new movie clip, with a depth value of 10, on the root timeline
named
. It then determines the next highest available depth in that same movie clip
file_mc
and creates a new movie clip called
at that depth.
edit_mc
this.attachMovie("menuClip","file_mc", 10, {_x:0, _y:0});
trace(file_mc.getDepth()); // 10
var nextDepth:Number = this.getNextHighestDepth();
this.attachMovie("menuClip", "edit_mc", nextDepth, {_x:200, _y:0});
trace(edit_mc.getDepth()); // 11
In this case, the variable named
contains the value 11 because that's the next
nextDepth
highest available depth for the
movie clip.
edit_mc
Do not use
with components; instead, use the depth
MovieClip.getNextHighestDepth()
manager. For more information, see "DepthManager class" in the Component Language
Reference. For more information on
, see
MovieClip.getNextHighestDepth()
getNextHighestDepth (MovieClip.getNextHighestDepth method).
To obtain the current highest occupied depth, subtract 1 from the value that
returns, as shown in the next section.
getNextHighestDepth()
Determining the instance at a particular depth
To determine the instance at a particular depth, use
.
MovieClip.getInstanceAtDepth()
This method returns a reference to the MovieClip instance at the specified depth.
The following code combines
and
to
getNextHighestDepth()
getInstanceAtDepth()
determine the movie clip at the (current) highest occupied depth on the root timeline.
var highestOccupiedDepth:Number = this.getNextHighestDepth() - 1;
var instanceAtHighestDepth:MovieClip =
this.getInstanceAtDepth(highestOccupiedDepth);
For more information, see
getInstanceAtDepth (MovieClip.getInstanceAtDepth
in the ActionScript 2.0 Language Reference.
method)
Managing movie clip depths
367

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents