Introduction to Flash CS5 ActionScript
ActionScript is a powerful scripting language in Adobe Flash Creative Suite that you can incorporate into your Flash CS5 movies to control playback, navigation, and imported media, such as images, video, and audio. ActionScript is written as a series of commands (or statements) that are placed on the timeline, buttons, movie clip, and external files using the Actions panel and the new Code Snippets panel. Think of ActionScript as a set of instructions you can give your movie to tell it how to behave and add abilities.
ActionScript is often used for timeline control so that animations can be told when and where to stop, loop, play, or jump to other points along a timeline. You can also make truly interactive movies by adding ActionScript to buttons on the stage so that users can control the animation, too.
The Flash CS5 Code Snippets panel
The Code Snippets panel contains dozens of useful pieces of code that you can easily apply in a single click. Whether you want to navigate the timeline, play sounds, or control video in your movie, a code snippet can help.
If you press the Enter or Return key to watch a movie clip play on the stage, you’ll probably be a little disappointed. Don’t worry: To see a movie clip in action, you just need to preview the movie in Flash Player.
The Flash CS5 Actions panel
If you’re comfortable writing code by hand, you can use the Actions panel to write your own code statements throughout your movie. The Actions panel acts as a wizard, reference book, and script editor all in one. You can also add actions from the Actions panel using a categorized tray or drop-down list or type them directly into the script editor. A handy Script Assist mode (see the next section) is available so that you can add and modify actions without having to type the code by hand. (We highly recommend the Script Assist mode for new users.)
To launch the Actions panel, choose Window→Actions or use the F9 (Windows) or Option+F9 (Mac) shortcut key combination.
To place an action on a frame, select the frame on the timeline and launch the Actions panel.
Flash CS5 Script Assist mode
For users new to ActionScript, an alternative to using the Code Snippets panel or tackling hands-on coding is Script Assist mode. This mode acts as a wizard within the Actions panel to let you use a series of menus, buttons, and text boxes to build scripts without having to get into the nuts and bolts of writing code by hand. Script Assist mode helps prevent time-consuming errors so that you spend more time being creative and less time troubleshooting.
To enable Script Assist mode, click the Script Assist icon in the upper-right corner of the Actions panel.
How to Preview your Flash CS5 ActionScript
ActionScript is understood and processed within Flash Player, so most scripted movies need to be tested by choosing Control→Test Movie.
In some cases, you can also enable simple actions in the authoring environment so that you can see your work in progress while still working from the timeline.