Chapter 2
92
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.
Summary of Contents for DIRECTOR MX-USING DIRECTOR MX
Page 1: ...Using Director MX Macromedia Director MX...
Page 12: ...Contents 12...
Page 156: ...Chapter 4 156...
Page 202: ...Chapter 6 202...
Page 244: ...Chapter 7 244...
Page 292: ...Chapter 10 292...
Page 330: ...Chapter 12 330...
Page 356: ...Chapter 13 356...
Page 372: ...Chapter 14 372...
Page 442: ...Chapter 16 442...
Page 472: ...Chapter 18 472...
Page 520: ...Chapter 19 520...
Page 536: ...Chapter 20 536...
Page 562: ...Chapter 23 562...
Page 566: ...Chapter 24 566...
Page 602: ...Chapter 27 602...