Building a Slideshow in Flash using ActionScript

by Milan Midovich.

Share
|
Homepage | Submit your article | Contact | TOS
More articles on flash  

You are here: Categories » Computers and technology » 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) {
   nextFrame();
   }

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:

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.

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.

Leave a comment or ask a question
Total comments: 0

Flash Disclaimer

  • The e-articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us to investigate the issue
Enhancing Standalone Projector - You want to create an enhanced Standalone Projector with features such as borderless playback, custom titles, no Flash menus, and so on. Use a third-party tool such as SWF Studio or SWFKit to c (more...)
Creating Flash Buttons - Buttons are one of the three main types of symbols that you use in Flash. The others are movie clips and graphics. Making a New Button There are many ways to create a button. One (more...)
Bouncing Ball Script - Start a new Flash movie. Create a movie clip that has a ball graphic inside it. You can name the instance of the movie clip, myClip, but our code will not depend on the name of the clip. (more...)
ActionScript: Creating Reusable Code - You want to perform a series of actions at various times without duplicating code unnecessarily throughout your movie. Create a function and then call (i.e., invoke) it by name whenever you (more...)
3D Scaling with ActionScript - Although Flash is not capable of real 3D graphics, the kind seen in popular computer games, you can create the illusion of 3D by using scaling. Scaling an object is a great way to give your (more...)
The Dot Syntax - Something else that you will be seeing a lot of as you learn ActionScript is dot syntax. Dot syntax is a way of grouping objects and functions that is used in many object-oriented programming (more...)
Movie Clip Scripts - Movie clip scripts, like button scripts, use handlers. Instead of using the on keyword that button scripts use, we will use the onClipEvent keyword. Here is an example of a movie clip script: (more...)
Decoding an RGB Value - You want to extract the red, green, and blue components from an RGB value returned by Color.getRGB( ). Use the bitshift right and bitwise AND operators. You can extract the red, gre (more...)
ActionScript: Generalizing a Function to Enhance Reusability - You want to perform slight variations of an action without having to duplicate multiple lines of code to accommodate the minor differences. Add parameters to your function to make it flexib (more...)
Scaling a Flash Movie - You want to control how a movie fits in the Player, including the scaling. Use the Stage.scaleMode property. The Flash Player defaults to a scale mode of "showAll" (except the tes (more...)

 
free content
    Copyright © 2006 - 2012 e-articles.info.
The texts, articles and tutorials in the directory are property of their respective owners and authors.