Button.getDepth( ) Method | Flash 6 |
returns the position of the button in the content stack |
An integer depth level.
Buttons, movie clips, and text fields are all placed in the Player in an order that governs how objects stack visually. An internal integer depth property indicates each object's order in the stack. The getDepth( ) method tells us theButton's integer depth position. Each depth level can have only one occupant, whether it is a text field, button, or movie clip. Objects on higher depths appear in front of those with lower depths.
Because all buttons are created at authoring time, Button.getDepth( ) always returns a depth in the range of -16383 to 0 (which is reserved for authored content). Unlike the MovieClip class, Button has no swapDepths( ) method, so each button's depth is fixed once it is assigned.
For much more information about depths, see Section 13.4 in Chapter 13.
Check the depth of cancel_btn, placed on the lowest layer of the main timeline:
trace(cancel_btn.getDepth()); // Displays: -16383
MovieClip.getDepth( ), MovieClip.swapDepths( ), TextField.getDepth( ); "Movie and Instance Stacking Order," in Chapter 13