View comments | RSS feed

swapDepths (MovieClip.swapDepths method)

public swapDepths(target:Object) : Void

Swaps the stacking, or depth level (z-order), of this movie clip with the movie clip that is specified by the target parameter or with the movie clip that currently occupies the depth level that is specified in the target parameter. Both movie clips must have the same parent movie clip. Swapping the depth level of movie clips has the effect of moving one movie clip in front of or behind the other. If a movie clip is tweening when this method is called, the tweening is stopped.

You can extend the methods and event handlers of the MovieClip class by creating a subclass.

Availability: ActionScript 1.0; Flash Player 5

Parameters

target:Object - This parameter can take one of two forms:

Example

The following example swaps the stacking order of two movie clip instances. Overlap two movie clip instances, called myMC1_mc and myMC2_mc, on the Stage and then add the following script to the parent Timeline:

myMC1_mc.onRelease = function() {
    this.swapDepths(myMC2_mc);
};
myMC2_mc.onRelease = function() {
    this.swapDepths(myMC1_mc);
};

See also

_level property, getDepth (MovieClip.getDepth method), getInstanceAtDepth (MovieClip.getInstanceAtDepth method), getNextHighestDepth (MovieClip.getNextHighestDepth method)


Flash CS3


Comments


robnewport said on Jul 5, 2007 at 3:12 PM :
for AS3, use setChildIndex ()
henke37_ said on Oct 6, 2007 at 3:04 PM :
This method does not perform any restrictions on the target deep, you can easily change deep levels from authoring time deeps to scripting deeps and back.
This allows bypassing of some restrictions like the deep restriction in the removeMovieClip method.

 

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

Current page: http://livedocs.adobe.com/flash/9.0/main/00001974.html