A Flash movie consists of scenes. Each scene has a timeline. Each timeline starts with frame 1 and continues from there. The natural state of a Flash movie is to move forward at a constant rate from scene 1, frame 1, to the end of scene 1 and then on to scene 2 and so on. You can set a movie to play through all the frames of all the scenes and stop. Or, you can set the movie to loop.
The primary purpose of ActionScript is to change this linear behavior. A script can stop a movie on a certain frame, loop back to a previous frame, or even give the user control of what frame is shown next . ActionScript can be used to make a movie completely break away from the passive linear mode of standard Flash movies.
But that's not all that ActionScript can do. It can also turn a Flash movie from an animation into an interactive computer program. Let's look at some of the basic functions that ActionScript can perform.
Animation You don't need ActionScript to create animation in Flash. But scripting can help to create some complex animation. For instance, a ball can bounce around the screen in a seemingly endless path with ActionScript. It can even obey the laws of physics, being pulled down by gravity. If you were to animate such a thing without ActionScript, you might need thousands of frames. But a script can do it in one frame.
Navigation Instead of the movie moving forward at a constant pace, you can pause it at a menu of choice and let the user decide where to go next.
User Input You can ask the user questions and use that information in the movie or send it to a server. A Flash movie with some ActionScript can be a better way to do a Web form. Or, the movie itself can use the information to customize the user's experience.
Get Data A script can interact with the server in the opposite direction, too. You can get up-to-date information and present it to the user.
Calculations ActionScript can take numbers and perform calculations with them. It can predict a mortgage payment or add up the cost of items in a shopping cart.
Graphic Alterations Scripts can be written to alter the size , angle of rotation, or even the color of movie clips in your movie. You can even duplicate or remove items from the screen.
Examine the Environment You can use ActionScript to examine the playback environment of a Flash movie. You can find out what time and date it is and what location the movie is being played from.
Play Sounds ActionScript is a good alternative to the Flash timeline for playing sounds. You can even control the balance and volume of a sound.
Expanding the Possibilities of Flash
The most important thing that ActionScript can do for you is something I can't list here ”because it hasn't been thought of yet. A powerful programming language such as ActionScript, combined with a strong imagination , can bring new and innovative results.
The purpose of this book is to teach you the basics of ActionScript so that you can use these building blocks to create your own masterpieces.
Next, we'll get a little more technical and look at exactly where ActionScript code fits into a Flash movie.