
TextField.getDepth() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
838
|
ActionScript Language Reference
TextField.getDepth() Method
returns the position of the text field in the content stack
Flash 6
theField.getDepth()
Returns
An integer depth level.
Description
Text fields, movie clips, and buttons are all placed in the Player in an order that governs
how objects stack visually. An internal depth property indicates each object’s order in the
content stack. The getDepth() method tells us a field’s integer depth position. Each depth
level can have only one occupant, whether the occupant is a text field, button, or movie
clip. Objects on higher depths appear in front of those with lower depths. For text fields
created at runtime with MovieClip.createTextField(), the return value of getDepth() is the
depth assigned to the method’s
depth parameter. For example:
// Sets depth to 13
this.createTextField("theField_txt", 13, 0, 0, 150, 20);
trace(theField_txt.getDepth()); // Displays: 13
For text fields created manually at authoring time, getDepth() returns a depth in the range
of –16383 to –1 (inclusive). Unlike the MovieClip class, TextField has no swapDepths()
method, so each text field’s depth is fixed once it has been assigned.
For much more information about depths, see “Movie and Instance Stacking Order” in
Chapter 13.
See Also
MovieClip.createTextField( ...