Free Webmaster Help Logo
Tutorials Articles Tools Images Directory Ask Newsletter
*
 

Tutorials
Cookies
ASP
Advanced HTML
Frames & Tables
.htaccess
Rounded Table Corners
Flash 5
FTP
Beginners
Javascript
PHP/MySQL
Site Promotion
Mobile Internet: WML/WAP
Server Side Includes (SSI)
HTML - The Basics
XHTML
Stylesheets
XML
PHP
*

125x125

Related Links
Macromedia Downloads
FlashKit
More Flash 5 Sites
*

 
Sitemap | Contact | Link To Us | Advertise
Report A Problem
Home : Tutorials : Flash 5 : Part 7

Flash 5 Tutorial
Part 7 - Actions

Introduction

In the last part of the tutorial I introduced you to actions in Flash using buttons to control your animation. In this part I will show you more of the things you can do with Flash 5's actions.

Inserting Actions

In the last part I showed you how to use an action with a button so that it was triggered when the button was clicked. Actions can also be added to frames and to other mouse events on the button. Firstly I will cover the buttons. If you haven't done so already make a simple button for your animation and right click on it and choose Actions. The actions window (which you first used last week) will appear. It has two windows. The one on the right contains the hundreds of actions you can add. The one on the left contains the code (like programming code). Choose an event (like Go To) and double click it to add it to the code. This is as far as you did in the last part.

What you didn't learn last week was that you can change what triggers the action. There are several options for this. To access them click on the part of the code which says:

on (release) {

A new section will now appear at the bottom of the box with the options for this part of the code (in Flash you write code by selecting options). Her you can choose what triggers the action. As you can see it is currently set as Release so when the mouse button is released the action will happen. This is fine for clicks but you may want to use some of the other triggers. To change the trigger just deselect the old one and select a new one. You can select more than one but just now I don't recommend it.

You can also trigger actions when a frame loads. Right click in any keyframe and choose Actions. This is exactly the same as the button Actions box except when you add an action there will be no:

on() {

code as the actions are executed when the frame is played.

Some Actions

I will now cover some of the actions you can add. Most of these will be available for both buttons and frames but some may not.

Go To

Go To, like its name suggests, makes the playback move to a different part of the movie. There are several options for this. You can choose the Scene in your movie to point to (if you are using multiple scenes), choose the type of Go To and the Frame. The type has several options but the 3 you will probably use most are Frame Number, Next Frame and Previous Frame. If you choose Frame Number, type in the box below which frame you want the movie to go to. Next and Previous frame are self explanitary.

The other option is the Go To and Play checkbox. If this is checked the movie will go to the specified frame (or scene) and will continue playing from that point. If you deselect it the movie will go to that frame but will only show that frame, and will not continue playing until another action tells it to.

Play and Stop

The Play and Stop actions have no parameters. One plays the movie from the current point and the other stops it (although it remains at its current position).

Toggle High Quality and Stop All Sounds

Toggle High Quality will switch the movie between high and low quality. Stop All Sounds will stop all the sounds currently playing in the movie. Neither of these have any parameters which can be set.

Get URL

This can be used for both frames and buttons. Basically, when clicked, it will point the browser to the specified URL. The URL is specified in the parameters for the action. You can also choose the window for the new page you are opening. This is the same as target in HTML. _blank will open in a new window and you can specify the name of a frame in here (if you are using them). The Variables option allows you to send the variables set in a form in your movie just like an HTML form (this is good for Submit buttons). You c
an choose between the standard POST and GET options.

If Frame Is Loaded

The If Frame Is Loaded is quite a complex but very useful command. It is used to make the 'loading' parts at the beginning of some Flash movies. It is used like an IF statement in a program. Double click the If Frame Is Loaded action to add it to the code, then double click the Go To action. You now have a small IF loop.

Firstly you should set the parameters for If Frame Is Loaded. Click on this part of the code. You will see that this is very similar to the Go To parameters. Here you select the frame you want to use. When this code is run it will check whether the specified frame has loaded yet, if it has then it will execute the code within the { and }.

Creating A 'Loading' Sequence

Many Flash animations on the internet, especially ones with a lot of sound and images, will not just start playing smoothly while they are still loading. For these, most people add a 'loading' part to their movie. This is a actually a few frames which will repeat until the movie is loaded. They are actually quite easy to make.

Firstly choose how many frames you will want for your 'loading' section. Something like 10 frames is about right. Create the part of the animation you want to loop in these frames. In the last frame of the 'loading' section right click to access the Actions menu. Double click on If Frame Is Loaded and then immediately afterwards double click on Go To. Then click on the final } in the animation and double click the Go To action again. You should now have the following code:

ifFrameLoaded (1) {
gotoAndPlay (1);
}
gotoAndPlay (1);

This is the code which will do the 'loading' part. Firstly click on ifFrameLoaded(1) and choose the frame you want to wait until it is loaded from the parameters. Click on the first gotoAndPlay(1) and choose frame 11 (if you used 10 frames for your 'loading' sequence). Finally, for the last gotoAndPlay(1) choose the first frame in your animation.

This is actually a very basic program, showing how easily complex programs can be written using Flash's actions. What the code actually does is to check if the specified frame is loaded. If it is it goes to the first frame of the acutal animation. Otherwise, it returns to the beginning and plays the 'loading' ssequence again.

Part 8

In this part I have shown you how you can use the Actions options in Flash to make your movie more interactive. In the next part I will show you how to include some sound into your movie.

© 1999 - 2001 FreeWebmasterHelp.com