User Guide
DepthManager.setDepthTo() 497
Parameters
depthFlag One of the following values: DepthManager.kTop, DepthManager.kBottom,
DepthManager.kTopmost, DepthManager.kNotopmost. All depth flags are static properties
of the DepthManger class. You must either reference the DepthManager package (for
example,
mx.managers.DepthManager.kTopmost) or use the import statement to import
the DepthManager package.
Returns
Nothing.
Description
Method; sets the depth of movieClipInstance to the value specified by depthFlag. This
method moves an instance to another depth to make room for another object. DepthManager
uses a “shuffling” algorithm to set the depths in increments of 20. The algorithm increments
depths in case Flash needs to insert something else in the middle, based on other scripts,
components, and so on.
Example
The following example uses two components (or movie clips) to raise their depth alternately
in increments of 20 as each one is clicked. First add a Button component to the Stage and give
it instance name
a_btn Then add another Button component to the Stage and give it instance
name
b_btn. Make sure the buttons overlap as follows:
import mx.managers.DepthManager;
a_btn.onRelease = function() {
b_btn.setDepthTo(DepthManager.kTop);
var b_depth:Number = b_btn.getDepth();
trace(b_depth);
}
b_btn.onRelease = function() {
a_btn.setDepthTo(DepthManager.kTop);
var a_depth:Number = a_btn.getDepth();
trace(a_depth);
}