Previous Page
Next Page

Tripod >> 3pod Tips & Learning and manuals for educations

Recipe 12.3. Adding Back and Forward Buttons to a Slide Presentation

Problem

You want to add back and forward buttons to a Slide presentation.

Solution

Add two button instances on the top-level slide and add ActionScript to instruct Flash how to respond when the user clicks the buttons.

Discussion

Though the Slide presentation adds keyboard navigation by default, it does not add any button-based navigation. You have to add that functionality yourself if you want it, requiring a fairly simple, two-step process:

  1. Add button instances to the top-level slide.

  2. Add ActionScript to tell Flash how to respond when the user clicks on the buttons.

Adding button instances is something with which you should already be familiar. If it is a new concept to you, review Chapter 9. Essentially, you want to create a back button symbol and a forward button symbol, and then drag instances of each symbol onto the top-level slide. Because you're placing the instances on the top-level slide, they will appear throughout the nested slides. An important thing to keep in mind is that all artwork on the top-level slide will appear below the artwork in the nested slides. Therefore, make sure that the button instances are not going to be hidden by artwork in the nested slides.

The next step is to add the appropriate ActionScript, so that Flash knows what to do when the buttons are clicked. Slide presentations in general do not tend to lend themselves to good coding practices, and to further complicate things, the required ActionScript is somewhat convoluted. Fortunately, however, you can apply some of the built-in behaviors from the Behaviors panel in order to have Flash apply the ActionScript for you:

  1. Select the back button instance on the slide.

  2. Open the Behaviors panel. If it is not already displayed as part of the panel set, you can open it by choosing Window Development Panels Behaviors or by pressing Shift-F3.

  3. Click the Add Behavior button (the plus sign in the Behaviors panel) to open the menu of behavior options, and choose Screen Go to Previous Slide. This command adds the necessary code for the button instance.

  4. Select the forward button instance on the slide.

  5. In the Behaviors panel, open the Add Behavior menu and choose Screen Go to Next Slide.

After you've completed these steps, you can test your applicationyou should be able to navigate between the slides using either the keyboard or the buttons you just added.

Although much of the code provided as behaviors can help you to get your simple applications working without knowing much Action-Script, the code they add does not necessarily represent good coding standards or best practices.


See Also

Recipe 12.2

Tripod >> 3pod Botom Tips & Learning and manuals for educations

Previous Page
Next Page

 

bluedot bluedots greydots pinkdots

Tripod >> 3pod Tips & Learning and manuals for educations