User Guide
Chapter 292
Add Lingo to navigation buttons
To make the navigation buttons function, you need to add scripts to the buttons. You’ll write
scripts attached to the button sprites, rather than to frames in the script channel. Your frame
scripts respond to
exitFrame events. Your button scripts will respond to mouse clicks.
You start by adding scripts to the buttons in the start scene.
1 In the Score, right-click (Windows) or Control-click (Macintosh) the Animation button sprite
in channel 2, frames 1 through 10.
2 In the context menu, select Script. The Script window opens with a default handler entered:
on mouseUp me
end
3
On the second line of the script, type:
go to frame "Animation"
You see the following result:
on mouseUp me
go to frame "Animation"
end
4
In the name text box at the top of the window, type GoAnim, close the Script window, and
save your movie.
This handler has three parts. The first line tells Director to trigger this handler when the user
clicks on the button sprite to which the script is attached. Specifically, the
mouseUp event refers to
the action of releasing the mouse button after it has been pressed. This way the script is not run
until the user releases the mouse button when clicking.
The second line of the handler contains the same code as the previous script you wrote. It
sends the playhead to the frame that contains the marker named Animation. The difference
between these two scripts is that this one performs its action based on a mouse click, not on
an
exitFrame event.
Again, the word end on the last line tells Director that the script is over.
Test your script
You’re ready to try out your new button script.
1 If necessary, bring the Stage window to the foreground by clicking in its title bar, and then
rewind and play your movie.
The movie plays, and the start scene remains on the screen. The playhead does not move to
another scene until you click your newly scripted button.
2 Click the Animation button on the Stage.
Notice that the button automatically provides feedback by changing color when it’s clicked.
The playhead moves to the first frame of the animation scene, and the sunset animation plays.
3 Stop your movie.