Assigning text to a text field at runtime

To assign text to a text field, use the TextField.text property.

To assign text to a text field at runtime:

  1. Using the Text tool, create a text field on the Stage.
  2. With the text field selected, in the Property inspector (Window > Properties), enter headline_txt in the Instance Name text box, directly below the Text Type pop-up menu on the left side of the inspector.

    Instance names can consist only of letters, underscores (_), and dollar signs ($).

  3. In the Timeline, select the first frame in Layer 1 and open the Actions panel (Window > Development Panels > Actions).
  4. Type the following code in the Actions panel:
    headline_txt.text = "Brazil wins World Cup";
    
  5. Select Control > Test Movie to test the movie.