Building a slideshow in flash using actionscript

Entry Notes

Posted: 07222007
Author: Milan Midovich
Category: Flash

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.

I've also placed the text "Slideshow Example" above everything else, stretched across all frames on its own layer. The contents of Frame 1, plus the way the timeline is set up.

The slideshow movie is set up with individual elements on each of the four frames plus some elements across all the frames.

Create a button. It can be as simple or as complex a button as you want.

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:

on (release) {

Now, select the first frame of the movie. 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:


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.

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.

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.

Related Articles

1. How to draw a line using ActionScript
Use the lineStyle( ) method to specify the thickness, color, and transpa...

2. Drawing an Ellipse using ActionScript
Create a custom MovieClip.drawEllipse( ) method using the Drawing API an...

3. ActionScript: Filling a Shape with a Gradient
Use the beginGradientFill( ) and endFill( ) methods to initiate and clos...

4. Scripting Masks in Flash
Use the Drawing API to create a shape and then use MovicClip.setMask( ) ...

5. Drawing a Triangle using ActionScript
Create a custom MovieClip.drawTriangle( ) method using the Drawing API a...

All articles in this directory are property of their respective authors.
Contact us | Terms of Service | Privacy Policy

© 2012 - All Rights Reserved.