H  1  2  3  4.1  4.2  4.3  5  6  7  8  9 

Hands-On: Flash MX 2004 the Basics

Exercise 7: Adding Scroll Buttons for a Dynamic Text Field

Continue with the previous exercise or re-open the dreamSpeech.fla file

The ActionScript for the Dynamically Linked Text Field will be the same as shown in the Dynamic Scroll Text Box exercise, the only difference here is that the text is Dynamically Linked instead of inserted on the Stage, which makes this exercise even more valuable to you.

Timeline layers

  1. The Library files. In the Timeline create a new layer above the holder layer and call it buttons. Click in the first frame of this button layer.
  2. From the Library [F11] attached to this practice file there are three folders, one each for buttons, graphics, and sound. In the button folder locate the btnDown button and drag it to the Stage and place it at the bottom right of the text area box.
  3. Click once on the new button and open the Actions panel [F9]. Choose the following steps: Click the Plus Mark + and then select
    Global Functions > Movie Clip Control > double-click on and then choose Release
    Selecting the Actions to use.
  4. Click to the right of the curly bracket } in the code area and then hit the [Enter] key.
  5. Choose the following steps:
    Click the Plus Mark + and then select
    Built-in Classes > Movie > TextField > Properties > scroll
    Selecting the Actions to use.The on Release actionScript code.
  6. To the right of the word scroll hit the [Space Bar] and type a Plus Sign + and then an Equals Sign = hit the [Space Bar] again and then type a 1 and a semi-colon ;
    This bit of code tells the button to stay where it is on the screen but every time you hit the down button scroll down one line of text. If you wished to scroll more than one line at a time, type a different number, such as 5, which would scroll 5 lines for each click of the button.
    So now your stage should look like the image below.
    The Stage version of the site.
  7. Back on the Stage, hold down the [Shift] key and the [Alt] key together, and then drag a copy of the Down Button with its ActionScript already made to the top of the text area box.
  8. Click off the button anywhere on the Stage (in case both are still selected), and then click back on just the Button placed at the top. Choose Modify > Transform > Flip Vertical to turn the arrow facing upwards.
  9. While still on the new Up button, hit [F9] to open the Actions panel, notice that the ActionScript is still there, but you have to change only one thing, the Plus Sign + now needs to be a Minus Sign – so the text can scroll back up. That’s it!
    The ActionScript for the button.
  10. Now test your movie again and you should be able to scroll up and down without difficulty.
    Screen shot of the actual Web page.
  11. The next part of this exercise adds a .WAV file of the speech and provides buttons for starting and stopping the sounds.

Download these files if you haven’t yet:

http://profal2.com/cis127/pdf/assets/flash/dreamSpeach.fla

http://profal2.com/cis127/pdf/assets/flash/dream.txt

 

Back to Top