Chapter 18. On-Screen Text Fields

Because Flash is fundamentally a visual environment, movies often present on-screen information to users. Similarly, because Flash is an interactive environment, movies often retrieve information from users through a GUI. To display the value of a variable on screen or to allow a user to type data into a Flash movie, we use text fields.

Text fields provide a means of both setting and retrieving the values of variables that have a visual representation. Text fields come in two varieties—dynamic text fields, which we use to display information to the user, and user-input text fields, which we use to retrieve information from the user.

Dynamic Text Fields

A dynamic text field is like a variable viewport—it displays the value of a specified variable as a text string. Dynamic text fields are created using the Text tool in Flash. However, unlike regular static text, the content of a dynamic text field is connected to a variable and can be changed or retrieved via ActionScript.

By retrieving a text field’s value, we can capture on-screen information for use in a script. By setting a text field’s value, we cause that value to display on screen.

Creating a Dynamic Text Field

To make a new dynamic text field, follow these steps:

  1. Select the Text tool.

  2. Click and drag a rectangle on the Stage. The outline that you create will define the size of the new text field.

  3. Select Text Options. The Text Options panel appears.

  4. In the Text Type menu, choose Dynamic Text (the other ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.