Action Scripts

 
In web design the programming language is HTML which may include some Javascript programming as well. Flash's programming language is called ActionScript. ActionScript allows you to write instructions for flash to follow in your movie. In this exercise you will add action scripts to make your buttons interactive.
 
  1. First, take a look at the actions panel. To view the actions panel go to Window > Development Panels > Actions. Here are the details of that panel.

2. Syntax is like sentence structure. Each programming language has its own way of putting code together and ActionScript is very picky about correct syntax so paying attention to details is important. You will now create an action script that loops one portion of a movie.

3. Create the following animation: Create a text box with the words "Welcome to Sequoia". Convert the text to a movie symbol and save it as Welcome Text. Save your file as Action_Script1.

4. Insert a keyframe in frame 20 and position the text in the middle of the stage. Move to frame one and move the text off the stage. Insert a tween and test the movie. The text should move to the center of the stage.

5. Insert a keyframe in frame 30 and add a tween to make the text rotate once CW. Test your movie, the text should appear from off the stage and then rotate once.

6. Add a new layer called Actions and move it so it is the top layer. It is a good practice to always create a layer for all of your actions. Click in frame 30 of the actions layer and insert a keyframe. Open the Actions panel. Be sure frame 30 is still selected in the Actions layer. You should see ations:30 in the Current Script Indicator tab of the actions panel.

7. Insert a gotoAndPlay action. To do this select Global Functions > Timeline Control from the toolbox and then double click on gotoAndPlay. What appears in the script pane?

8. This action requires more information, information that you must provide called a parameter. Parameters always go inside the parenthesis ( ). If you click inside the ( ) a code hint box will open to help you. Type 20 inside the (20) because that is where you want to go and play. Test your movie and describe what it does.

9. The one problem with this script is that if you changed the location of the keyframes then you would have to go back into the script and change the gotoAndPlay frame number. A better way is to make a frame label. Click in frame 20 of the actions layer and insert a keyframe. In the properties panel type in a frame label of "Start_Loop". What changes on the timeline?

10. Now go back to the script and instead of 20 in the parenthesis type in "Start_Loop". Test the movie.

11. Go to the timeline and click and drag frame 20 of the action layer to frame 10. Test the movie. Describe what happens this time.

12. Demonstrate your movie to your instructor and show your action script as well for teacher check.