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

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Determining the depth of an instance
To determine the depth of a movie clip instance, use
The following code iterates over all the movie clips on a SWF file's main timeline and shows
each clip's instance name and depth value in the Output panel:
for (var item:String in _root) {
var obj:Object = _root[item];
if (obj instanceof MovieClip) {
var objDepth:Number = obj.getDepth();
trace(obj._name + ":" + objDepth)
}
}
For more information, see
ActionScript 2.0 Language Reference.
Swapping movie clip depths
To swap the depths of two movie clips on the same timeline, use
The following examples show how two movie clip instances can swap depths at runtime.
To swap movie clip depths:
1.
Create a new Flash document called swap.fla.
2.
Draw a blue circle on the Stage.
3.
Select the blue circle, and then select Modify > Convert to Symbol.
4.
Select the Movie clip option, and then click OK.
5.
Select the instance on the Stage, and then type first_mc into the Instance Name text box
in the Property inspector.
6.
Draw a red circle on the Stage, and then select Modify > Convert to Symbol.
7.
Select the Movie clip option, and then click OK.
8.
Select the instance on the Stage, and then type second_mc into the Instance Name text box
in the Property inspector.
9.
Drag the two instances so that they overlap slightly on the Stage.
10.
Select Frame 1 of the Timeline, and then type the following code into the Actions panel:
first_mc.onRelease = function() {
this.swapDepths(second_mc);
};
second_mc.onRelease = function() {
this.swapDepths(first_mc);
};
368
Working with Movie Clips
getDepth (MovieClip.getDepth method)
MovieClip.getDepth()
in the
MovieClip.swapDepths()
.
.

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