Basic Action Scripting
An Action Script is a programming command that tells Flash to execute an action. There are two places an action script can be. One place is for time based events, and the other place is for user action based events. Before you begin to write a script, you need to be aware of where you are placing the script.
[IMPORTANT!] Where you are placing a script is determined by what you click on before you begin writing your script.
Time Based Events
When you want a script to do something when the movie reaches a certain frame or when it reaches a certain scene, the script needs to be placed on the timeline. This means that you have to CLICK on a specific keyframe before you start writing a time based script.
- Timeline Action Scripts should be on its own named top-most layer.
- If there is no keyframe at that point in time you need one, you need to make one
User Action Based Events
When you want a script to react to something the user clicks on, you need to place the script onto the object that the user clicks on. This means that you have to CLICK on the specific object or button before you start writing a user action based script.
Project Overview
After your name animation plays, the navigation scene plays. At the end of your navigation scene, you want your movie to stop (on the navigation scene). When the user clicks on any of the buttons, the movie jumps to another scene. At the end of any of the scenes, the movie returns to the navigation scene.
Placing Scripts Onto Your Timeline
Without any scripts, your movie will play through each scene in the order that it appears in your scene palette. This means that you want your first scene to be your name animation scene, and your second scene to be the navigation scene.
To make the navigation scene stop at the end:
- Go to your navigation scene.
- Add a new layer and name it “Actions”
- Add a keyframe at the very end of your “Actions” layer
- Select this last keyframe.
- Open your Action Script Editor.
Window Menu > Development Panels > Actions
- Add a new item to your script
click on the plus sign.
- Select Global Functions > Timeline Control > Stop
At the end of any scenes after the Navigation Scene, we want the movie to return to the Navigation scene.
For each scene after the Navigation scene:
- Add an actions layer and begin to place a script at the end of the scene
(see steps 1-5 of the previous instructions)
- Add a new item to your script
click on the plus sign.
- Select Global Functions > Timeline Control > GotoAndPlay
The first part of a script will be added, and a cursor will appear inside parenthesis.
- Type the name of you navigation scene in quotes followed by a comma then the number one. ACTION SCRIPT IS CASE SENSITIVE. Your script should look something like this:
gotoAndPlay("Navigation",1);
Adding Scripts to Buttons
- Click on a button ON THE STAGE.
- Open the script editor and add a new item to your script.
- Define the action that will trigger this script. For this button that means selecting:
Global Functions > Movie Clip Control > on
A drop down menu will appear. Double click on release
- Move the cursor to the right of the open curly bracket (click there) and type a return.
- Add a new item to your script
- Select Global Functions > Timeline Control > GotoAndPlay
- In quotes, type the name of the scene you want the button to go to when clicked, followed by a comma and the number 1. Your script should look something like this:
on (release) {
gotoAndPlay("Expanded Square",1);
}
Edited 4-11-06 |