First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Patrick Jansen | Website: http://orbita.starmedia.com/~pjv

Adding the scrollbuttons and nessary triggers.

Open Movie Clip scrollDown and create 3 empty keyframes. At frame 1, insert the action:

stop ();

At frame 2 insert the actions

currentScroll = _parent.windowtext.scroll;
max = _parent.windowtext.maxscroll;
if (currentScroll < max) {
    _parent.windowtext.scroll = currentScroll+1;

Let's look at what this does. First the variable currentScroll is set to the current scollvalue of scrolltext. It will return the number of the current topmost textline. Next, the variable max is set to the maximum textline which can show up as line 1 in the textfield scrolltext. For example, if your text is 40 lines and your textfield shows 7 lines, then max will result in a value of 33 (40 - 7) since when line 33 is shown as line 1 in the textfield, it will show the rest of the text till line 40. Next comes an If statement. We just want to scroll untill it reaches the maximum scroll, so we check if the current textline is less then the maximum scrollable textline. If it is less, the continuously executed action in frame 2 of the loop frame 2 - frame 3 will create a scrolling effect by getting the current scroll line and adding up 1 line, and we close the If statement.

To create a loop between frame 2 and 3, add the following action to frame 3

gotoAndPlay (2);

Now we'll repeat this for the Movie Clip scrollUp but with a little difference in the scrollaction. Frame 1, insert action:

stop ();

At frame 2 insert the actions

currentScroll = _parent.windowtext.scroll;
max = _parent.windowtext.maxscroll;
if (currentScroll > 1) {
    _parent.windowtext.scroll = currentScroll-1;

And in frame 3 the action

gotoAndPlay (2);

The difference with scrollDown is in the If-statent of scrollUp. Because the initial scrollvalue of a textfield is always 1, the first line of the textfield, we check that currentScroll (the current scroll value - read 'current visable first line number') is greater then 1. This way the text will scroll up only until it reaches the first line. This is done by the action between the If -statement, where we get the current scrollvalue of scrolltext and counting down 1 line.

Noticed the use of _parent ? If you are a little bit familiar with Action Script you probably get this right away. If you got confused, the _parent indicates one level lower in the hierarchy of flash movieclips and/or loaded movies. currentScroll and max are local variables within the trigger Movie Clips scrollUp and scrollDown. These 2 Movie Clips are placed in the Movie Clip textMC. scrolltext.scroll and scrolltext.maxscroll are properties of the textfield scrolltext which is directly situated in Movie Clip textMC. To addres properties from a Movie Clip with actions which reside within a nested Movie Clip, you need to use _parent before the variable.

Later we will need to add one more line of important Action Script to frame 2. This line will keep setting the position of the dragable scrollbar when the scroll up or down buttons is clicked and held.

» Level Intermediate

Added: 2001-01-25
Rating: 8 Votes: 123
(10 being the highest)
» Author
Patrick Jansen is a freelance flash-, graphic- and webdesigner. Born in Holland, currently residential in Brazil. Worked for the compagnies Lectric b.v. (www.lectric.nl) and NIC b.v. (www.notenbomer.nl).
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


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

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.