The Actions panel is Flash's ActionScript-editing environment. Every script in a movie is created in the Actions panel, which is accessed via Window Actions (F9).
The Actions panel can operate in Expert Mode or Normal Mode. When in Expert Mode, the panel is divided into two sections: the Toolbox pane (on the left) and the Script pane (on the right), as shown in Figure 16-1.
The Script pane houses code attached to the currently selected frame, button, or movie clip. The Toolbox acts as both a quick reference guide and a means of adding code to the Script pane. Double-clicking any item in the Toolbox adds that item to the Script pane. Items can also be dragged from the Toolbox into the Script pane.
The Actions panel's title bar indicates whether our current code lives on a frame ("Actions - Frame"), a button ("Actions - Button"), or a movie clip ("Actions - Movie Clip"). When code cannot be attached to the current selection, the Actions panel title is simply "Actions", and the Script pane is disabled.
The Actions panel's pop-up Options menu button provides access to various tools and settings, such as printing and enabling line numbers. The script navigation bar indicates the exact location of the current script and can be used to navigate quickly between scripts on the current timeline.
The organization of the items in the Toolbox differs somewhat from the categories used in this book to describe the features of ActionScript. Most notably, in the Toolbox, statements are not separated into their own folder, and classes and objects are grouped together under the Objects folder. In this book, we distinguish between statements, classes, and objects in keeping with more traditional programming terminology. For an alphabetical list, use the index at the bottom of the Toolbox or, of course, this book's ActionScript Language Reference.
The Actions panel has two different modes of operation, Normal Mode and Expert Mode, which govern how we add code to the Script pane.
In Normal Mode, the Toolbox is used to build new statements, and the Script pane is used as a viewer for those statements. To add a new statement to the Script pane in Normal Mode, we double-click the desired Action or drag an Action from the Toolbox to the Script pane. To add a statement of arbitrary code, we select the evaluate Action (under Actions Miscellaneous Actions) and enter the statement into the Expression field of the Parameters pane at the top of the Actions panel (the Parameters pane is not shown in Figure 16-1).
After adding a statement to the Script pane, we can customize it via the Parameters pane at the top of the Actions panel. The layout and contents of the Parameters pane change to suit the statement selected in the Script pane. Notice that when the Actions panel is operating in Normal Mode, code cannot be entered directly into the Script pane. In Normal Mode, the Script pane is not a text-editing environment, but rather a read-only list of statements; alterations to statements in the Script pane are performed through the Parameters pane.
Normal Mode is comforting for new programmers but constricting for most nontrivial programming projects. In this book, therefore, we use only the Expert Mode to author code. However, with the exception of multiline comments (which can be used only in Expert Mode), any code produced in one mode can also be produced in the other.
In Expert Mode, the Script pane functions as a traditional text-editing window. When authoring or changing code in Expert Mode, we enter text directly into the Script pane. However, we can still double-click items in the Toolbox to add them to the Script pane. The Parameters pane is not used in Expert Mode; instead, parameters are typed directly into the Script pane.
In Flash 5, the editing mode of the Actions panel is set on a per-frame and per-object basis. That is, Flash remembers the editing mode chosen for every object and frame in a movie. If we select Normal Mode for frame 2 and Expert Mode for frame 3, the Actions panel automatically switches to Normal Mode when we edit the code on frame 2 and Expert Mode when we edit the code on frame 3.
In Flash MX, the editing mode of the Actions panel is a permanent toggle, accessed via the pop-up Options menu shown in Figure 1-2 in Chapter 1.
In Flash 5, the editing mode can be set globally under Edit Preferences General Actions Panel Mode.
In Flash 5, switching from Expert Mode to Normal Mode destroys all source-code formatting. The code is reformatted according to Flash's standard formatting rules�extra whitespace is lost, and statement block indentation is adjusted to match the style shown throughout this book. In Flash MX, source-code formatting is preserved between mode switches.