The Basics of ActionScript
The Actions Panel
The tool you will use is the Actions panel. It is designed for both the hard core coder and those of you new to ActionScript and even coding. There are a variety of tools to help you check your syntax (Syntax is a fancy term for Grammar and Spelling), format your scripts and even help you along.
- Open a new Flash document, select frame one and press the F9 key (PC) or press Option-F9 if you are a Mac user. Alternatively, select Window>Actions.
The Actions panel will open. You will notice it is broken into sections: Actions toolbox, Script Pane, Script navigator, and a toolbar containing such buttons as ScriptAssist and a pop down menu that lets you choose the ActionScript version( FlashLite is used for SWFs destined for cell phone playback) to be used in the project.
Code can be placed on the main timeline or objects on the stage such as buttons and movie clips. The Script Navigator let’s you easily move through these various bits and pieces of code and change them, if necessary.
The Actions toolbox is like having an ActionScript dictionary sitting on your desk. The toolbox contains a series of “books” which can be clicked to open them. When a book is open all of the methods, actions and properties are available. Double click one of them and it will be added to the Script pane wherever you have clicked the mouse.
- Click once in the Script pane.
With the “books” visible, click the Global Functions book. A series of other books will appear under it. Click the Timeline Control book to open the pages associated with timeline control. Double click the gotoAndPlay page. The code, with a hint telling you what goes between the brackets, will appear where you clicked in the Script Pane.
- Press the Return/Enter key and type the following line of code:
gotoandplay();
The first thing you will notice is the text is all black while the same text in the line above is blue. This is a visual hint that Flash believes that you are using your own function, rather than one provided by Flash. You misspelled the keyword. Change the “a” in and to”A” and the “p” in play to “P”. As soon as you change the “P”, the phrase turns blue. Text that is black in ActionScript is inevitably due to a user-created variable, function or object. Text that is blue in ActionScript is a keyword and it must be spelled properly.
Select the line you just entered and press the Delete key to remove it.
- Click the Check Syntax button- it looks like a check mark- on the Actions toolbar.
Even though the code was “correct” you still received a syntax error and the Output panel opens
Click OK to close the Alert box.The panel will give you the line of code where the error occurred and suggest a remedy. In this case you are being told the gotoAndPlay() event needs one or two parameters not a “1” or a “2”.
Click once between the brackets and enter the number “2”. Click the Check Syntax button and the Alert will tell you “This script contains no errors”. Click OK to close the Alert and then close the Actions panel by clicking the Close button.
When the Actions panel closes you will see a small letter “a” has been added to the frame where you entered your script. This is Flash telling you that there is ActionScript associated with the frame.
- Select the frame on the timeline containing your script and press F9 (PC) or Option-F9 (Mac).The Actions panel will open and you will see your script. Delete the code and close the Actions panel. The “a” will be removed from the frame where the script was located.
As you start working with ActionScript a good habit to develop is to click the Check Syntax button after you write a piece of code. Though not to be regarded as a Debugging tool, this feature is very good at catching such glaring errors as missing parameters, missing brackets, incorrect variables and so on.
Throughout this course you will see that I recommend putting all ActionScript on its own layer named “Actions”. This has become a standard industry practice. By keeping all of the code in one place, you can quickly access the code when problems develop.


This work is licensed under a Creative Commons License.
