ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > TextField > getDepth (TextField.getDepth method) | |||
public getDepth() : Number
Returns the depth of a text field.
Availability: ActionScript 1.0; Flash Player 6
Number - An integer that represents the depth of the text field.
The following example demonstrates text fields that reside at different depths. Create a dynamic text field on the Stage and add the following ActionScript code to your FLA or AS file. The code dynamically creates two text fields at runtime and outputs their depths.
this.createTextField("first_mc", this.getNextHighestDepth(), 10, 10, 100, 22);
this.createTextField("second_mc", this.getNextHighestDepth(), 10, 10, 100, 22);
for (var prop in this) {
if (this[prop] instanceof TextField) {
var this_txt:TextField = this[prop];
trace(this_txt._name+" is a TextField at depth: "+this_txt.getDepth());
}
}
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player 7 or later. If your SWF file includes a version 2 component, use the version 2 components' DepthManager class instead of the MovieClip.getNextHighestDepth() method.
|
|
|
|