TextField._name Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
TextField._name Property Flash 6

the instance name of the TextField object read/write
theField._name

Description

The string _name property specifies a field's instance name, which is specified initially via the Property inspector at authoring time or via the MovieClip.createTextField( ) method at runtime. Though rarely (if ever) necessary, setting _name reassigns the instance name for theField; thereafter, references to the old instance name yield undefined:

// Create a text field with an instance name of address_txt this.createTextField("address_txt", 1, 0, 0, 200, 60); // Reassign the instance name address_txt._name = "location_txt"; // Now access the field through the new instance name location_txt.text = "Toronto, Canada";

More commonly, the _name property is used to identify a specific text field when processing fields as a group. For example, the following code processes a hypothetical form. It finds the field email_txt on the current timeline (this) and then invokes a data-validating function on it:

for (var p in this) {   if (this[p] instanceof TextField) {     // Show each field's name     trace("found " + this[p]._name);     // Look for email_txt     if (this[p]._name =  = "email_txt") {       validateAddress(this[p].text);     }   } }

See Also

MovieClip.createTextField( ), MovieClip._name; "The for-in Loop," in Chapter 8



    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