TextField.variable Property | Flash 6 |
associates a variable with the text property | read/write |
The string variable property is a backward-compatibility feature that specifies a regular variable whose value will mirror the value of theField.text. This allows for direct Flash 5-style assignment of a value to a text field. The following example creates a text field object with an instance name of firstName_txt and associates it with the variable userName. Subsequent assignments to userName are displayed in firstName_txt and reflected by its text property.
this.createTextField("firstName_txt", 1, 0, 0, 200, 20); firstName_txt.variable = "userName"; // Displays "Colin" on screen userName = "Colin"; // Check the text property trace(firstName_txt.text); // Displays: Colin
Conversely, assignments to firstName_txt.text are reflected by the variable userName:
firstName_txt.text = "Bruce"; trace(userName); // Displays: Bruce
The variable reference can be constructed with dot notation, allowing variables on objects and other timelines to be used:
firstName_txt.variable = "_level0.someClip.someVariable";
When exporting to Flash 5 and prior versions, the variable property must be set in the Flash MX authoring tool, in the Property inspector under "Var:". When coding for Flash 6, the variable property should be avoided in favor of the text property.
Note that the variable property stores the name of the variable, not its value. It is used only to establish the link between a regular variable and theField.text:
trace(firstName_txt.variable); // Displays: userName
TextField.htmlText, TextField.text