Assigning text to a text field at runtime
To assign text to a text field, use the TextField.text
property.
- Using the Text tool, create a text field on the Stage.
- 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 ($).
- In the Timeline, select the first frame in Layer 1 and open the Actions panel (Window > Development Panels > Actions).
- Type the following code in the Actions panel:
headline_txt.text = "Brazil wins World Cup";
- Select Control > Test Movie to test the movie.