O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing Manually Created Text

In the preceding sections, we learned three tools for accessing manually created symbol instances through ActionScript:

  • The getChildAt( ) method

  • The getChildByName( ) method

  • Automatically assigned instance variables

The same three tools can also be used to access manually created text. In the Flash authoring tool, text fields are created with the Text Tool. Manually created text fields of type Dynamic Text or Input Text are represented at runtime by instances of the flash.text.TextField class. Like symbol instances, Dynamic and Input text fields become display children of the object representing the timeline that contains them. Also like symbol instances, Dynamic and Input text fields can be assigned an instance name that corresponds to an automatically assigned instance variable.

For example, the following steps describe how to move a manually created Dynamic text field to coordinate (200, 300) using ActionScript:

  1. In the Flash authoring tool, create a new .fla file name message.fla.

  2. In the Tools panel, select the Text Tool.

  3. Click the Stage of the first frame of message.fla's main timeline.

  4. In the text field that appears, enter the text hello.

  5. On the Properties panel (Window → Properties), change Static Text to Dynamic Text.

  6. Still on the Properties panel, for <Instance Name>, enter msg.

  7. Click the first frame of message.fla's main timeline (select it).

  8. Open the Actions panel (Window → Actions).

  9. Enter the following code into the Actions panel:

    msg.x = 200; msg.y = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required