Using the Actions Panel/ActionScript Editor
Obviously, the premise of this book requires you to concentrate on writing scripts. It's a good idea to get familiar with the tools you'll use in Flash to do so. In this, your first exercise, you'll learn some of the basics of creating scripts with the ActionScript editor.
NOTEThe purpose of this book is to teach ActionScript, not so much how to use the Flash interface. This discussion will be concise, providing enough information to help you progress through the book. For a more extensive look at the many features of the Actions panel, pick up the Macromedia Flash Visual QuickStart Guide.
With Flash open, choose File > New and choose Flash Document from the list of choices. Press OK.This step creates a new Flash document. It's usually a good idea to give your document a name and save it, so we'll do that next.From the File menu, choose Save As. In the dialog box that appears, navigate to any folder on your hard drive where you would like to save this file (it's not important where, really), name it myFirstFile.fla, and press the Save button.After you press Save, the tab at the top of the document window will reflect the name of your new file.Open the Actions panel by choosing Window > Development Panels > Actions.Let's look at the various sections of the Actions panel.

myMovieClip_mc.
NOTELet's assume this is the name of a movie clip instance we've placed in our movie.Immediately after you type the dot (.), a drop-down menu provides a list of actions applicable to movie clip instances.

NOTEFor a complete list of suffixes, consult the ActionScript Dictionary.Select the current script and delete it. In its place, type:
This line of script creates a new Sound object named mySound. Creating a Sound object using this syntax identifies mySound as a Sound object to the ActionScript editor. As a result, referencing this object by its name later in the script will cause a drop-down menu of appropriate Sound objectrelated commands to appear automatically. Let's test it.Press Enter/Return to go to the next line in the Script pane, and type:
var mySound:Sound = new Sound();
Once again, immediately after typing the dot, you see a drop-down menu with a list of actions applicable to Sound objects.You can create a new Sound object using this syntax:
mySound.
but this syntax will not activate the functionality of code hinting when you script that object, as the syntax in Step 5 does.To help you grasp this concept, let's look at a couple more examples.This code activates Color objectrelated code hinting for the myColor Color object:
mySound = new Sound();
This code does not:
var myColor:Color = new Color();
This code activates Date objectrelated code hinting for the myDate Date object:
myColor = new Color();
This code does not:
var myDate:Date = new Date();
myDate = new Date();
NOTETo clarify, in this book we will be using suffixes only when naming visual elements such as movie clip instances, text fields, and buttons. This is because visual elements are not created in the same manner as the description in this step. Using suffixes in their names is the only way to activate code hinting when referencing them in the ActionScript editor.Let's look next at another type of code hint available in the ActionScript editor.Select the current script and delete it. Type in its place:
getURL(


TIPYou can rid the interface completely of dimmed-out interface elements by pressing F4. Pressing F4 again brings them back.Another noticeable change is the disappearance of the Script Navigator. Once again, because this mode is meant for editing .as files, the concept of navigating various scripts in a project has no meaning, and the Script Navigator is nonexistent in this mode. Other than these differences, the ActionScript editor works in the same manner as previously discussed in this exercise.When you create .as files (as you'll be doing later in the book), you save them by choosing File > Save and providing a name.
NOTEIn most cases in this book, unless otherwise stated, .as files (once we begin creating them) should be saved in the same directory as your main .fla files.One last thing to note about the Flash authoring environment is that two tabs now appear at the top of the document window. One tab represents the Flash document we created in Step 1, and the other represents the open ActionScript file we just created. Clicking on these tabs allows you to switch easily between authoring the Flash document and the ActionScript file. Flash automatically switches editing modes when you do.
