About text field instance and variable names

In the Property inspector, you can also assign a variable name to a dynamic or input text field, as well as an instance name. You can then refer to the text field's variable name in ActionScript, whose value determines the text field's contents. A text field's instance name and variable name should not be confused, however.

You use the instance name assigned to a text field to invoke methods and get and set properties on that text field. A text field's variable name is simply a variable reference to the text contained by that text field; it is not a reference to an object.

For example, if you assigned a text field the variable name mytextVar, you could then set the contents of the text field using the following code:

var mytextVar = "This is what will appear in the text field";

However, you couldn't use the mytextVar variable to set the same text field's text property to some text.

//This won't work
myTextVar.text = "A text field variable is not an object reference";

In general, use the TextField.text property to control the contents of a text field, unless you're targeting a version of Flash Player that doesn't support the TextField class. This will lessen the chances of a variable name conflict, which could result in unexpected behavior at runtime.