DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 8.1 Referring to a Text Field via ActionScript

8.1.1 Problem

You want to refer to a text field via ActionScript.

8.1.2 Solution

Refer to author-time text fields by their instance names.

8.1.3 Discussion

Many of the recipes in this chapter require you to access a text field's methods or properties. Sometimes text fields are created at runtime via ActionScript, but often you'll want to adapt a recipe to work with your author-time content.

ActionScript refers to author-time text fields using the text field instance name, which must be set, as follows:

  1. Select the text field instance on the Stage.

  2. Open the Property inspector.

  3. Change the text field's type from "Static Text" to "Dynamic Text" (change it to "Input Text" if you want to allow user input at runtime).

  4. Specify an instance name in the Property inspector (the instance name field appears once you complete Step 3).

8.1.4 See Also

To refer to a text field created at runtime, use the TextField instance returned by MovieClip.createTextField( ), as demonstrated in Recipe 8.2. For details on creating editable text fields, see Recipe 8.5.

    [ Team LiB ] Previous Section Next Section