Task: Simple Text Scrolling

I l @ ve RuBoard

It is actually easy to create a simple scrolling text field. If you throw out the complexities of a full scrollbar, and just keep the up and down arrow keys, you can make it with only a few lines of code.

In this example, we'll build a movie with a dynamic text field and two buttons . You can see what it could look like in Figure 14.3.

Figure 14.3. This simple scrolling example has only two buttons.


  1. Find some text to paste into a text field. Make it at least 20 lines long, with paragraphs that are longer than one line so that it looks like text you would find in a book.

  2. Start a new Flash movie.

  3. Create a dynamic text field by using the Text tool.

  4. Bring up the properties dialog and name this text field scrollText. Make sure you give it the name scrollText, which is different than linking it to a variable named scrollText. Set it to Multiline and select Show Border Around Text.

  5. Paste the text you have selected in step 1 into the text field.

  6. Create two buttons, an Up button and a Down button.

  7. Attach this script to the Up button. It will scroll the text field back up by one line:

     on (press) {     scrollText.scroll--; } 
  8. Attach this script to the Down button. It will scroll the text field down by one line:

     on (press) {     scrollText.scroll++; } 
  9. Test the movie. You should be able to scroll up and down using these two buttons. Check out 14simplescroll.fla to see another example.

I l @ ve RuBoard

Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net