Flash 8 Cookbook
Authors: Lott J.
Published year: 2007
Pages: 186-187/336
Buy this book on amazon.com >>

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



Recipe 12.4. Adding Transitions to Slide Presentations

Problem

You want to add transitions (fades, wipes, and so on) to your Slide presentation.

Solution

Use the built-in transitions and apply them to the slides.

Discussion

Flash Professional includes a set of standard transition effects you can use to determine how slides will animate when appearing and disappearing . You can add these transition effects to your slides using the Behaviors panel. To do so, just complete the following steps:

  1. Select the slide in the Screen Outline pane for which you want to add the transition effect.

  2. Open the Behaviors panel (Window Development Panels Behaviors or Shift-F3).

  3. Click on the plus button to open the Add Behavior menu, and choose Screen Transition.

  4. In the Transitions dialog box, choose the options, including the type of transition, the direction (in or out), the duration of the transition in sections, the type of easing, and any other options specific to the transition type. Then click OK.

  5. If you want to add a second transition, repeat steps 3 and 4. For example, you may want to add a transition for the slide as it appears and another for when it disappears. A transition applied to the in direction corresponds to the appearance of the slide, and a transition applied to the out direction corresponds to the disappearance of the slide.

See Also

Recipe 12.2


Flash 8 Cookbook
Authors: Lott J.
Published year: 2007
Pages: 186-187/336
Buy this book on amazon.com >>