Working with Text > Controlling text with ActionScript

 

Controlling text with ActionScript

A dynamic or input text field is an instance of the ActionScript TextField object. When you create a text field, you can assign it an instance name in the Property inspector. You can use the instance name in ActionScript statements to set, change, and format the text field and its content using the TextField andTextFormat objects.

The TextField object has the same properties as the MovieClip object, and has methods that let you set, select, and manipulate the text. The TextFormat object lets you set character and paragraph values for the text. You can use these ActionScript objects instead of the text Property inspector to control the settings of a text field.

You can use a text field's variable name or instance name to assign it text that contains HTML tags. Flash preserves the rich text formatting applied to the text field with ActionScript.

If you assign a variable to a text field, the text field displays the variable's value. You can use ActionScript to pass the variable to other parts of the movie, to a server-side application for storing in a database, and so on. You can also replace the value of the variable by reading it from a server-side application or by loading it from another part of the movie. For more information on using variables, see About variables. For more information about connecting to external applications, see Connecting with External Sources.