Actions Panel

   

The Actions panel lets you add and edit actionsstatements that add interactivity to a movie while it is playingapplied to an object or a frame. It consists primarily of two panes: a library of actions in the left pane, and parameters and the script in the right pane (see Figure 9.1). In the Actions panel's option menu, you can select from two modes: Normal and Export.

Figure 9.1. The Actions panel consist of two main panes.

graphics/09fig01.gif

NOTE

The left pane of the Actions panel can be collapsed or expanded by clicking the arrow located between the two panes.


Normal Mode

Normal mode is recommended for those who are just getting introduced to ActionScript. When in Normal mode, the parameters are clearly laid out for you, whether they pertain to an action, a function, an operator, a property, or an object. Figure 9.1 is an example of what the Actions panel looks like in Normal mode.

Expert Mode

Expert mode is appropriate for the more seasoned programmer who feels comfortable enough to write code without the help of the parameters portion of the right pane. Once you're in Expert mode, the parameters section is no longer there (see Figure 9.2). In fact, much of the assistance given to you in Normal mode is gone in Expert mode. But in Expert mode, you're free to write code as you wish.

Figure 9.2. In Expert mode, the Actions panel leaves out the parameters section.

graphics/09fig02.gif

TIP

When you switch from Expert mode to Normal mode, any code that is not correct is pointed out so you can fix it before you enter Normal mode. This is a handy tool to make sure all of your code is correct.


ActionScript Toolbox

A list of all potential ActionScript types is neatly laid out for you in a toolbox in the left pane of the Actions panel (see Figure 9.3). The list is arranged in a branching menu system that lets you pick the appropriate script for any specific need. For example, if you wanted to use an action that controls movie playback, you would select an action from the Movie Clip Control drop-down list. Table 9.1 explains how this ActionScript toolbox is broken down, and when to use each category.

Figure 9.3. All of Flash MX's ActionScript categories are neatly compiled in a toolbox found in the left pane of the Actions panel.

graphics/09fig03.gif

Table 9.1. ActionScript Toolbox Categories

CATEGORIES

CONTENTS AND DEFINITIONS

Actions

Contains a list of all actions that can be added to your script. An action is a statement that adds interactivity to a movie while it is playing.

Operators

Contains a list of all operators that can be used with expressions. (Expressions are any combination of ActionScript symbols that represent a certain value.) An operator is an item that calculates a new value based on one or more values.

Functions

Contains a list of all functions that can be used with expressions. A function is a reusable code block that parameters can be passed to and returns a specific value.

Constants

Contains a list of global constants that can be used with expressions. A constant is an item that does not change.

Properties

Contains a list of all properties that can be used with movie clips. A property is a parameter that defines an object.

Objects

Contains a list of all predefined objects provided by ActionScript. An object is a set of methods and properties.

Deprecated

Contains a list of features that should be avoided in new content. A deprecated action is an action that can be coded better with another action. They are kept here for your convenience because they've been in previous versions of Flash.

Flash UI Components

Contains a list of all Flash UI ( user interface) components. New to Flash MX, Flash UI components are used for Flash MXbased applications.

Index

Contains an index of all items in alphabetical order.

NOTE

This toolbox of code is available in both Normal and Expert modes.


Adding Action

ScriptActionScript can be applied to an objecta button or movie clip instanceor to a frame. To do so, always be sure you have the item or frame to which you wish to add ActionScript selected first. You can then go through the ActionScript toolbox, find the action you wish to add, and double-click it. Once you select an action, the script is laid out for you in the scripting pane. You can also add ActionScript by clicking the plus sign (+) in the Actions panel. All the items in the ActionScript toolbox are also located in this plus-sign drop-down menu system. Finally, you can write the script out yourself in Expert mode within the scripting pane of the Actions panel. Whenever an action is placed on a frame, it is denoted in the Timeline with a lowercase A (a) .

TIP

Notice the title of the Actions panel. If you select an object to which you want to add an action, the panel's title changes accordingly to either ActionsButton or ActionsMovie Clip. If you select a frame to which you want to add the action, the panel's title changes to ActionsFrame.


Editing ActionScript

Editing ActionScript is done very similarly to the way you add ActionScript. To edit ActionScript in Normal mode, you can select the line of code that you wish to edit and change its parameters within the parameters portion of the Actions panel. To edit in Expert mode, simply go into the scripting pane of the Actions panel, select the code you wish to edit, and type over it.

To delete ActionScript in Normal mode, select the script in the scripting pane and click the minus sign () in the Actions panel, which is located right next to the plus sign (+). In Expert mode, simply select the script to be deleted and press the Delete button on your keyboard.

ActionScript Syntax

Like any other language, ActionScript has rules of grammar and punctuation. How these rules are used will determine the meaning of what's being scripted. Let's take a look at what key attributes make up ActionScript's syntax.

Dot Syntax

In ActionScript, dot syntax is used to put objects, properties, and methods together to form statements. It is also used to indicate the target path to a movie clip, function, object, or variable. A dot syntax expression begins with the name of the item followed by a dot (.) and ends with the element you wish to specify.

Dot syntax uses two main aliases: _root and _parent . The alias _root refers to the Flash document's main Timeline. This alias can be used to create an absolute target path. The alias _parent refers to a movie clip in which another movie clip resides. This alias can be used to create a relative target path.

TIP

Dot syntax has replaced the slash syntax that was used in previous versions of Flash. You can still use slash syntax but dot syntax is more compatible with all the new actions in Flash MX.


Keywords

ActionScript has a list of words that are placed on reserve for specific use, so you cannot use them as a variable or function. Below is a list of these keywords:

  • break

  • case

  • continue

  • default

  • delete

  • else

  • for

  • function

  • if

  • in

  • instanceof

  • new

  • return

  • switch

  • this

  • typeof

  • var

  • void

  • while

  • with

Comments

Comments, which are used to add notes to your ActionScript, come in handy to note what script does what. They also help when you need to pass your document off to another team of people who need to work on your Flash MX document. Comments can be added by using the Actions panel. When you choose the Comment action from the Actions panel, two forward slashes ( // ) appear in your script, followed by the comment. By default, comments are rendered pink in the Actions panel. Comments don't add file size to your final exported movie.

NOTE

Comments don't need to follow the rules and syntax of ActionScript. You can type them in any way you wish.


Semicolons

Just as an English statement closes with a period, an exclamation point, or a question mark, an ActionScript statement closes with a semicolon. If a semicolon is not at the end of a statement, Flash still renders your script successfully. Just get in the habit of closing all statements with a semicolon to follow proper ActionScript syntax.

Parentheses

Whenever you are defining or talking to a function, you need to place any and all parameters within parentheses.

Curly Braces

Curly braces are another form of punctuation that ActionScript uses frequently. ActionScript statements are grouped with curly braces ({ }). These curly braces are usually found separated on different lines to make all related ActionScript statements easier to read and follow.


   
Top


Certified Macromedia Flash MX Designer Study Guide
Certified Macromedia Flash MX Designer Study Guide
ISBN: 0321126955
EAN: 2147483647
Year: 2001
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net