• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 6. Adding Basic Interactivity > Adding Actions to Button Instances

Adding Actions to Button Instances

You already know how to stop the movie. In this section, you'll use actions to activate the buttons in the Navigation Buttons layer so that you can navigate to each section of the site.

1.
Select frame 15 of the Actions and Labels layer in neptune28.fla, and open the Frame panel.

You used the Frame panel in Lesson 4 when you applied tweening to some frames. Now you'll use it to apply labels to keyframes in the Actions and Labels layer. Each keyframe in this layer marks a new section of the movie.

2.
In the Label text box, type Home.

Frame 15 is essentially the home page of your developing movie. When you set the label in the Frame panel, you should be able to see it in the timeline as well, provided that enough frames follow the labeled frame for Flash to display the label.

3.
Select frame 20 of the Actions and Labels layer. In the Label text box of the Frame panel, type Reservations. Use the Frame panel to set the following labels for each of the other keyframes in this layer: frame 25 to Activities, frame 30 to Games, frame 35 to Journal, and frame 40 to About.

Each section of your movie is now labeled. By labeling the sections, you can add actions that refer to specific sections, rather than frames. That way, if you wanted to add more frames between sections (to add more animation, for example), you would still be able to refer to the labeled section.

4.
Select frame 15 of the Navigation Buttons layer; then select the instance of the Invisible Button. In the Frame Actions panel, locate the Go To action in the toolbox list, and add it to the actions list.

The following ActionScript is added to the actions list:

on (release) { 
 gotoAndPlay (1);
}

The first line of this ActionScript tells Flash to do something on (release), which means that when the mouse button is pressed and released, everything inside the curly braces ({}) should happen. The next line tells Flash to gotoAndPlay (1);—specifically, to go to frame 1 and play the movie from there.

5.
Select the line that says gotoAndPlay (1);. In the parameters pane, set the type to Frame Label and the frame to Home, and deselect the Go To and Play option.

Your ActionScript should now look like this:

on (release) { 
gotoAndStop (“Home”);
}

With just a few simple changes, you modified the ActionScript so that when the mouse button is released, the movie goes to and stops at the frame labeled Home.

The Frame setting has a drop-down menu containing all of the labeled frames in the movie, so you can select the necessary frame label from that menu.

6.
Repeat steps 4 and 5 for each of the other buttons in the Navigation Buttons layer, setting the frame to the label that corresponds with the button.

Just select each button in turn, and apply the Go To action to it. Make sure that you set the type to Frame for each button, and set the frame to the appropriate frame for the button. The Reservations button goes to the Reservations frame, the Activities button goes to the Activities frame, and so on.

7.
Close the Actions panel, and choose Control > Enable Simple Buttons. Click each of the buttons in the Navigation Buttons layer to see what the movie does.

If a check appears next to the Enable Simple Buttons command, it's already selected, so you don't have to select it again. When you click each button, the movie should jump to the appropriate frame. You should be able to see the playhead move to each frame.

8.
Save your movie as neptune29.fla in the MyWork folder.

You're done adding buttons for now. In the next part of this lesson, you'll work with a different sort of interactivity: creating forms in Flash.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint