I'm not going to supply a lot of information about the ActionScript in this example because it's rather tedious, and the important thing about the script is that there's no need to change it. It's designed to work with any size and shape of scrolling text box with two buttons and a dragging slider on a track.
You need to upgrade your Flash player (v.9 or later) to view this example.
The structure is this: One movie clip (textclip_mc) contains everything. The dimensions of textclip_mc are not important to the script; they can be changed. The following movie clips are inside textclip_mc:
If you download the FLA, you'll find that the ActionScript is all in Frame 1 on the Timeline, and it's pretty thoroughly commented.
You need to upgrade your Flash player (v.9 or later) to view this example.
The version above has the same script and different graphics. There's another difference in the "red" version: The ActionScript is not on the main timeline but instead is embedded in the Text Device movie clip symbol. That means all references to textclip_mc have been removed. If you duplicated the Text Device clip in the Library, you could use two in the same movie. Or three, four ... as you like. The frame rate is also faster in the "red" version -- 30 fps, compared with 15 fps for the green version above it.
Of course you could use externally loaded text with this script instead of embedded text (as used in the examples here). I think this scrollbar is really bulletproof, and the script can be adapted in all kinds of ways. What's possibly more important is that the graphics can all be adapted -- and even replaced -- and the functionality will not be affected. So long as you use the instance names shown above, the script will work with any shape or size buttons, track, text field, etc.
If you need a tutorial on instance names and how they work with EventListeners and functions, see this: Flash Basics: AS3 Buttons.
DOWNLOAD The files can be downloaded from this folder.
Education use: This package was created as an example for my journalism students. It is not intended to be used commercially.
Use and re-use:
A Versatile Scrollbar for Scrolling Text in Flash CS4 (AS3) by Mindy McAdams is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Updated 3 March 2011