Tutorials » Interactivity: Useability: ActionScript for Flash 5 dummies: Scrolling a text box - Page 2
Setting things up
Okay, first of all you'll need to make two buttons: up and down. They can be of any shape you want. You may want to give the buttons a big hit area so that the user can be slightly off the button and still be able to scroll.
Next you'll need to make a textbox. Just click on the text tool and let your inspiration carry you. You can let the text overflow, we'll fix this later.
Now select the text and go into the « Text Options » panel. Set the options as in this screenshot:

If you can't seem to find the panel, it's in Window > Panels > Text options. Here's what each of the options do:
- We choose dynamic text, since it is the only kind of textbox where you can
alter the scroll property in actionscript. There's a nice side effect to using
dynamic text: unless you choose to embed your fonts, the text will not be
anti-aliased, so it will look good even at small sizes.
- Choosing Multiline will allow the text to spread across multiple lines.
- We set the variable name to "daTextBox" here. We'll use this name
later to refer to the textbox in ActionScript.
- By choosing HTML, we can apply basic formatting on the text ( color, size,
bold, italics, and hyperlinks )
- Word wrap works in conjunction with multiline to allow the text to wrap.
There is something peculiar in the way Flash handles text boxes and scrolling: you can't scroll a text box unless you fill its contents using ActionScript. In order to do this, you can load external text files into Flash, but that's much beyond the scope of this tutorial. Right now, we're just going to place the contents of the text box directly in Actionscript (a technique called «hard-coding» ).
There's an easy way to transfer the text ( or rather, the underlying HTML ) from the text box to ActionScript. When you test your movie (Ctrl+enter), you can see a list of the variables in the movie by going to the Debug menu and choosing « List Variables ». You should see something similar to this:

As you can see, the HTML content of the text box is accessible (it's on the second-to-last line, in this case). Select all of the HTML, copy it, and then paste it into Notepad or a similar program. Save this for later use.
Once this is done, you can go back to your Flash movie, and safely delete the contents of the text box. You should reduce its height as well, otherwise there won't be a need for scrolling.
Finally, place your text box and your two buttons on the main timeline, select everything, and press F8 to convert to a movie clip. Name it «containerMC» . Our setup is now done.
| » Level Basic |
|
Added: 2001-06-20 Rating: 8 Votes: 400 |
| » Author |
| No details available. |
| » Download |
| Download the files used in this tutorial. |
| Download (12 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!