Working with Text > Controlling text with ActionScript > Using text field events to trigger scripts |  |

Using text field events to trigger scripts

You can use ActionScript to capture events that happen to text fields, for example, you can determine whether a user has changed or scrolled the text. You can write ActionScript statements that use these events to trigger scripts to run.

You can capture the following text field events: `onChanged` and `onScroller`.

To use a text field event to trigger a script:

1 | Do one of the following:
| Use the Text tool to drag a text field on the Stage. Assign the text field an instance name in the Property inspector.
| Use ActionScript to create a text field dynamically with the `createTextField` method. Assign the text field an instance name as a parameter of the `createTextField` method.
2 | In the Actions panel, select the Objects category in the Actions toolbox, then select the Movie category, then select the TextField category, then select the Events category, then double-click an event. For this example, use the `onChanged` method.
3 | In the Object parameter box, enter the instance name of the text field from step 1.
4 | Add ActionScript statements inside the function. These statements run when the text field is changed.

For more information on events of the TextField object, see the TextField object in the online ActionScript Dictionary in the Help menu.