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.
In
the Timeline create a new layer above the holder layer and call
it buttons.
Click in the first frame of this button layer.
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.
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
Click to the right of the curly bracket } in
the code area and then hit the [Enter] key.
Choose the following steps:
Click the Plus Mark + and then select Built-in Classes > Movie > TextField > Properties > scroll
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.
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.
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.
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!
Now test your movie again and you should be able to scroll up and down without
difficulty.
The next part of this exercise adds a .WAV file of the speech and
provides buttons for starting and stopping the sounds.