Example: Creating scrolling text

You can use several methods to create scrolling text in Flash. You can make dynamic and input text fields scrollable by selecting the Scrollable option from the Text menu or the context menu, or by pressing Shift and double-clicking the text field handle.

You can use the scroll and maxscroll properties of the TextField object to control vertical scrolling and the hscroll and maxhscroll properties to control horizontal scrolling in a text field. The scroll and hscroll properties specify the current vertical and horizontal scrolling positions, respectively; you can read and write these properties. The maxscroll and maxhscroll properties specify the maximum vertical and horizontal scrolling positions, respectively; you can only read these properties.

The TextArea component provides an easy way to create scrolling text fields with a minimum amount of scripting. For more information, see "TextArea component" in the ActionScript 2.0 Components Language Reference.

To create a scrollable dynamic text field:

Do one of the following:

To use the scroll property to create scrolling text:

  1. Do one of the following:
  2. Create an Up button and a Down button, or select Window > Common Libraries > Buttons, and drag buttons to the Stage.

    You will use these buttons to scroll the text up and down.

  3. Select the Down button on the Stage and type down_btn into the Instance Name text box.
  4. Select the Up button on the Stage and type up_btn into the Instance Name text box.
  5. Select Frame 1 on the Timeline, and, in the Actions panel (Window > Actions), enter the following code to scroll the text down in the text field:
    down_btn.onPress = function() {
        textField_txt.scroll += 1;
    };
    
  6. Following the ActionScript in step 5, enter the following code to scroll the text up:
    up_btn.onPress = function() {
        textField_txt.scroll -= 1;
    };
    

    Any text that loads into the textField_txt text field can be scrolled using the up and down buttons.


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000941.html