Adobe Flash Professional CS6 Adobe Flash Professional CS6 Classroom In A Book | Page 249
Using the gotoandPlay command
The gotoAndPlay command makes the Flash playhead move to a specific frame on
the Timeline and begin playing from that point.
1 Select the first frame of the actions layer and open the Actions panel.
P Note: A fast and
easy way of doing
multiple replacements
is to use the Find and
Replace command in
the Actions panel. From
the options menu in
the upper-right corner,
select Find and Replace.
2 In your ActionScript code, change all the first four gotoAndStop() commands
to gotoAndPlay() commands. Leave the parameter unchanged:
•
gotoAndStop("label1"); should be changed to
gotoAndPlay("label1");
•
gotoAndStop("label2"); should be changed to
gotoAndPlay("label2");
•
gotoAndStop("label3"); should be changed to
gotoAndPlay("label3");
•
gotoAndStop("label4"); should be changed to
gotoAndPlay("label4");
For each of the restaurant buttons, the ActionScript code now directs the
playhead to a particular frame label and begins playing at that point.
Make sure you keep the function for your Home button unchanged. You’ll want
that function to remain a gotoAndStop() command.
Stopping the animations
If you test your movie now (Control > Test Movie > in Flash Professional), you’ll see
that each button goes to its corresponding frame label and plays from that point,
but it keeps playing, showing all the remaining animations in the Timeline. The
next step is to tell Flash when to stop.
1 Select frame 19 of the actions layer, the frame just before the label2 keyframe on
the content layer.
240
Lesson 6
Creating Interactive navigation