Task: Slideshow
A slideshow is a simple presentation where you have various screens, or slides, presented one after the other. This is similar to how a plain Flash movie would work, except that without scripts, the movie would continue rather quickly through these frames.
Instead, we'll use scripts to pause the movie on each frame. To continue it, we will use buttons that allow the user to advance to the next frame whenever she wants.
-
Create a new Flash movie. Place four different pieces of text or graphic on the first four frames. The example movie 05slideshow.fla contains the words "Frame 1" through "Frame 4" and a different shape on each frame.
-
Create a button. It can be as simple or as complex a button as you want. In Figure 5.4, you can see my Next button at the bottom right.
-
Make sure that the button is placed on a layer so that it stretches across all four frames of the movie. Check the example movie if you are not sure how this should look.
-
Attach a script to the button. Make sure that you have the button and not the frame selected. The Actions panel should have the title Actions - Button at the top. Here is the script:
-
Now, select the first frame of the movie. In Figure 5.4, you can see that one of the layers, Layer 1, has four separate key frames, and the other layer, Layer 2, has one key frame that stretches across all four frames. Select the first key frame in Layer 1 and open the Actions panel. Its title should now be Actions - Frame. Looking at the title of the script panel is a good way to confirm that you are writing a frame script, not attaching one to a movie clip. Place this simple script in the script panel:
-
Choose Control, Test Movie to see it in action. The movie starts at Frame 1 and then pauses. You can then click the Next button to advance to Frame 2. You can keep advancing until you get to Frame 4.
I've also placed the text "Slideshow Example" above everything else, stretched across all frames on its own layer. The result is partially shown in Figure 5.4. You can see the contents of Frame 1, plus the way the timeline is set up.
Figure 5.4 The slideshow movie is set up with individual elements on each of the four frames plus some elements across all the frames.
on (release) { nextFrame(); }
stop();
This stops the movie from rapidly advancing from Frame 1 through Frame 4. We want it to stop at Frame 1 and await the user.
The movie will not advance past Frame 4 because the nextFrame command will simply do nothing if there are no more frames. You could have placed the Next button in every frame except the last one so that the button will not even appear there.
Next, we'll build a much more complex presentation movie.