Table of Contents

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


Table of Contents