Macromedia Flash 8 for Windows & Macintosh

The Actions panel takes up a good deal of room on your screen. You can resize the panel and its panes or collapse panes completely. You can customize the way scripts appear in the Script pane to view them in the smallest typeface you can read, for example (or, if you've spent long hours staring at tiny onscreen type, you can make scripts display in nice large letters). You can choose settings for font and type size; you can set Flash to highlight different types of script elements in different colors; you can control the number of spaces Flash uses to indent with each tab you type; and you can turn code hints on or off.

Two Types of Actions

This book uses two types of scripts: scripts that attach to keyframes and scripts that attach to objects. You can create both types by entering code directly in the Script pane of the Actions panel or by using Script Assist or the Behaviors panel. Before entering a script or choosing a behavior to create a script for you, first select the keyframe or object to which the script belongs.

Frame-based scripts are sets of actions attached to a keyframe. In the final exported movie, when the playhead reaches a keyframe that contains a script, Flash carries out the script's instructions. More advanced ActionScripters can create frame-based scripts that control all interactivity in the movie, responding not only to frame-based cues but also to object-based events, for example, a user clicking a button.

Object-based scripts are sets of actions attached to buttons, movie clips, or components (compiled clips). Actions attached to buttons usually require input from someone who is viewing the movie. In a text-heavy frame, for example, you can make the movie pause until the user clicks a button that instructs Flash to resume playback. Actions attached to movie clips and components can also respond to user input.

More advanced scripters can use ActionScript to trigger movie-clip actions without user interventionfor example, to make all sounds stop playing when a movie clip first appears. In addition, advanced ActionScripters can create scripts that target text fields, performing operations that modify them or retrieve information from them. Text fields on their own, however, can't have attached scripts.

To set preferences for the Actions panel

1.

From the Edit menu (Windows) or from the Flash application menu (Mac), choose Preferences.

or From the Options menu in the top-right corner of the Actions panel, choose Preferences.

The Preferences dialog appears.

2.

In the Category list, select ActionScript.

The settings for working with statements in the Script pane of the Actions panel appear in the main window of the Preferences dialog (Figure 13.2).

Figure 13.2. In the Preferences dialog, choose the ActionScript category to access settings for customizing the way Flash displays your scripts.

3.

To get scripting help from code hints, in the Editing section, select the Code Hints check box.

Move the lever of the Delay slider to set the amount of time Flash waits before displaying the hint as you type directly in the Script pane.

4.

To choose the font for writing scripts, in the Font section, do the following:

  • From the pop-up menu of installed fonts, choose a font.

  • From the pop-up menu of sizes, choose a type size.
The Actions panel can display scripts in text as small as 8 points and as large as 72 points.

5.

To color-code script items, in the Syntax Colors section, select the Code Coloring check box (Figure 13.3).

Figure 13.3. Activate syntax coloring by selecting the "Syntax colors: Code coloring" check box in the ActionScript category of the Preferences dialog. Change the colors to make more of a distinction between scripting "words" to begin getting a feel for ActionScript's parts of speech.

Using the color controls to access a pop-up set of swatches, choose new colors for any of the following:

Foreground. The basic text color for your scripts. Keywords. Words reserved for special purposes in ActionScript.

Identifiers. The names of things, such as objects, variables, and functions, that are built into ActionScript. Identifiers are also used for custom classes for which you've defined an .xml file for code hints.

Background. The color against which your script displays in the Script pane.

Comments. Text that Flash ignores when it reads the script, used to make notes about what's going on in the script.

Strings. Series of characters (letters, numbers, and punctuation marks). Strings generally appear inside quotation marks.

6.

Click OK.

Flash applies your preferences settings immediately.

Tips

  • Flash's default settings for keywords and identifiers are similar shades of blue. Try setting them to wildly different colorssay, pink and orange. This technique will help you learn to recognize these different parts of ActionScript speech as they're used in the scripts you create.

  • You may want to color-code only certain parts of your scripts. If, for example, you want your comments to appear in a different color but nothing else, set the color controls for Keywords, Identifiers, and Strings to match the color you choose for Foreground.

  • Code hints work like tool tips within the Actions panel when Script Assist isn't active. With code hints turned on, you can make the Actions panel display certain types of scripting information in a tool-tip-type box or drop-down menu. Position the insertion point to the right of a dot (a period character) or an opening parenthesis in the Script pane, and then click the Show Code Hints button. If you enable Code Hints in the ActionScript Preferences, the hints appear automatically whenever you type a period or opening parenthesis.

Категории