Creating Interaction with ActionScript > Creating a scrolling text field
Creating a scrolling text field
You can use the scroll
and maxscroll
properties to create a scrolling text field. To scroll the text, click the buttons in the movie.
In the Text Options panel, you can assign a variable to any text field set to Input Text or Dynamic Text. The text field acts like a window that displays the value of that variable.
Each variable associated with a text field has a scroll
and a maxscroll
property. You can use these properties to scroll text in a text field. The scroll
property returns the number of the topmost visible line in a text field; you can set and retrieve it. The maxscroll
property returns the topmost visible line in a text field when the bottom line of text is visible; you can read, but not set, this property.
For example, suppose you have a text field that is four lines long. If it contains the variable speech
, that would fill nine lines of the text field, and only part of the speech
variable can be displayed at one time (identified by the solid box):
You can access these properties using dot syntax, as in the following:
textFieldVariable.scroll myMovieClip.textFieldVariable.scroll textFieldVariable.maxscroll myMovieClip.textFieldVariable.maxscroll
To create a scrolling text field:
1 | Drag a text field on the Stage. |
2 | Choose Window > Panels > Text Options. |
3 | Choose Input Text from the pop-up menu. |
4 | Enter the variable name text in the Variable field. |
5 | Drag the text field's bottom right corner to resize the text field.
![]() |
6 | Choose Window > Actions. |
7 | Select frame 1 in the main Timeline and assign a set variable action that sets the value of text . |
No text will appear in the field until the variable is set. Therefore, although you can assign this action to any frame, button, or movie clip, it's a good idea to assign the action to frame 1 on the main Timeline, as shown here:
![]() |
|
8 | Choose Window > Common Libraries > Buttons, and drag a button to the Stage. |
9 | Press Alt (Windows) or Option (Macintosh) and drag the button to create a copy. |
10 | Select the top button and choose Window > Actions. |
11 | Drag the set variables action from the toolbox to the Script window in the Actions panel. |
12 | Enter text.scroll in the Variable box. |
13 | Enter text.scroll -1 in the Value box and select the Expression check box. |
14 | Select the Down Arrow button and assign the following set variables action: |
text.scroll = text.scroll+1; |
|
15 | Choose Control > Test Movie to test the scrolling text field. |
![]() |
For more information about the scroll
and maxscroll
properties, see their entries in the ActionScript Dictionary.