Button.getDepth( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Button.getDepth( ) Method Flash 6

returns the position of the button in the content stack
theButton.getDepth()

Returns

An integer depth level.

Description

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.

Example

Check the depth of cancel_btn, placed on the lowest layer of the main timeline:

trace(cancel_btn.getDepth());  // Displays: -16383

See Also

MovieClip.getDepth( ), MovieClip.swapDepths( ), TextField.getDepth( ); "Movie and Instance Stacking Order," in Chapter 13



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net