Download (direct link):
Figure 4-13: The pinned script from frame 1 is opened at the same time as the unpinned script from frame 2.
4. You can pin more than a single script if you want. If we continued this example, we could also pin the script from frame 2 and then open a script from frame 3 as shown in Figure 4-14.
Figure 4-14: You can pin more than one script at a time.
You can also use the keyboard shortcuts to quickly pin and unpin scripts. In order to pin the current script, press Ctrl+= or ^+=. To unpin the current script, press Ctrl+- or ^+-. You can also unpin all pinned scripts either by selecting the Close All Scripts option from the Actions panel menu or by pressing Ctrl+Shift+- or §ˆ +Shift+-.
Setting Actions Panel Preferences
The Actions panel has its own set of preferences that you can adjust to your liking. You can access the preferences either from the Actions panel pop-up menu (the Preferences menu item) or by opening the Preferences dialog box (Edit Î Preferences) and selecting the ActionScript preferences tab. Figure 4-15 shows the ActionScript preferences.
General Editing Clpboard Warnings ActionScript
Editing options 0 Automatic indentation 0 Code hints Tab size: 4
Delay: 3 0 seconds
Open/Import: UTF-8 Z0
Save/Export: UTF-8 3
Courier New j 10 vj
0 Syntax coloring
Foreground: Ù Background: ~J
Keywords: Ö Comments:
Identifiers: Ö Strings: Ù
[ ActionScrpt2.0SeKngs... |
| Reset to Defaults ~]
OK | | Cancel | | HeJp
] >j Layer 1 ;3|^Ä|@ Layer 1 ; 1 [[•] Layer 1 2 \ Line 1 of 1, Col 1
IB Layer 1=2|-ì|Â Layer 1 8 1| Line 1 of 1, Col 1
Figure 4-15: The ActionScript Preferences tab
Chapter 4 ¦ Learning ActionScript Basics
As you can see from the picture, the ActionScript preferences are categorized into four groups: Editing Options, Text, Syntax Coloring, and Language. Let’s take a closer look at each of these sections.
Flash is capable of automatically detecting and placing indentation in your code as you write it. For instance, after you type the following and press Enter, Flash can automatically indent the next line:
Then, when you type the next closing brace (}), Flash automatically unindents that line.
In the ActionScript Editor preferences, you can turn off Automatic Indentation by unchecking the box, or you can adjust the amount that it indents (Tab size). By default, the Tab size is set to 4, meaning the tab value is equal to the width of four spaces.
Code hinting is on by default. You can turn it off by unchecking the box, and you can adjust the rate at which the code hints appear. By default, code hints appear immediately. You can use the slider to change the number of seconds before code hints appear. For more information regarding code hinting in general, see the section “Using Code Hinting.”
Additionally, you can select the format that Flash uses to open/import or save/export a file.
You can adjust the font and font size used in the Script pane by changing the preferences in the Text section of the ActionScript Editor preferences.
The Actions panel has a syntax-highlighting feature that you can modify in the ActionScript Editor preferences. After unchecking the Syntax Coloring box, all text appears in black on white within the Script pane. Leaving the box checked, however, color-codes your script. Six types of syntax are distinguished for the purposes of color coding:
¦ Foreground is anything that doesn’t fall into any other category.
¦ Keywords include all the items grouped within the Statements folder in the Actions toolbox as well as items grouped in Compiler Directives.
¦ Identifiers include predefined class names, constants, predefined functions, properties, and methods.
¦ Strings include all quoted strings.
You can modify the colors used to suit your own preferences.
The Language portion of the ActionScript preferences allows you to adjust the ActionScript 2.0 settings. We discuss this in greater detail in upcoming chapters.
80 Part II ¦ Laying the ActionScript Foundation
Working with Formatting
ActionScript gives you flexibility in how you format your code. With a few exceptions, you can use spaces, carriage returns, and indentation as you please without affecting the way in which the code works. There are many styles for writing code that programmers choose to adopt. But whatever style they choose, chances are good that each programmer will remain fairly consistent with his or her own style. Doing so ensures that the code remains more readable.
For several reasons, you may find that your code is not consistently formatted. For example, you might be drawing together snippets of code from various sources, or you simply might not have applied consistent formatting along the way. For this reason, Flash offers you an auto-formatting feature that you can access either from the Actions panel toolbar or from the Actions panel pop-up menu. Auto Format follows a set of rules that you can adjust, and formats the selected code uniformly.