Wednesday, November 5, 2008

Code for stopping the animation

In a Flash movie, ActionScript can be placed in keyframes on the timeline, on movie clips, inside movie clips (on movie clip’s own timeline) and on buttons. ActionScript cannot be placed inside a button!

Press F9 (ALT+F9 on a Mac) or choose Window > Actions and the Actions panel will appear. On top of the window, Actions - Frame should be written, indicating that you are entering the code in a keyframe. Click inside the area for code writing (the right side of the Actions panel) and type


stop();


Close the Actions panel. You should see a small letter “a” inside the frame 15 on the actions layer of your timeline. That is Flash’s way of indicating that some ActionScript code is to be found on that frame.

Test your movie (Control > Test Movie) and you should see it stop right in the middle of animation. Close the movie test window. Now, there is no way of making the animation continue, unless we place something in our movie that will make it possible (or delete the ActionScript we just entered, which we don’t want to do). So, let’s place a button in our movie that will enable us to start the animation again.

No comments: