344
USING FLASH CS4 PROFESSIONAL
ActionScript
Check syntax and punctuation
You can do a quick check of your ActionScript code without publishing the FLA file.
When you check syntax, the current script is checked. If the current script calls ActionScript classes, those classes are
also checked. Other scripts that might be in the FLA file are not checked.
For ActionScript 2.0 files, Check Syntax runs the code through the compiler, generating syntax and compiler errors.
For ActionScript 3.0 files, Check Syntax generates only syntax errors. To generate compiler errors, such as type
mismatches, improper return values, and variable or method name misspellings, you must use the Control > Test
Movie command.
Check syntax
•
In the Actions panel or Script window, click Check Syntax
.
•
From the panel menu
(at the upper-right corner of the Actions panel), select Check Syntax.
•
Click in the Script pane, and then press T (Windows) or T (Macintosh).
Syntax errors are listed in the Compiler Errors panel.
Note:
In an external ActionScript class file in the Script window, the global classpath (AS2) or source path (AS3) affects
the syntax check. Even if the global classpath or source path is set correctly, you might generate errors, because the
compiler is not aware that this class is being compiled. For more information about ActionScript 3.0 classes, see
Objects
and classes
in Programming ActionScript 3.0. For more information on compiling ActionScript 2.0 classes, see Compiling
and exporting classes in Learning ActionScript 2.0 in Adobe Flash at
www.adobe.com/go/learn_fl_cs4_learningAS2_en
.
Check for punctuation balance
1
Click between braces {}, brackets [], or parentheses () in your script.
2
In Windows, press ' (single quote); on the Macintosh, press ' (single quote). The text between
braces, brackets, or parentheses is highlighted, and you can check that opening punctuation has corresponding
closing punctuation.
Import and export scripts
You can import a script into the Actions panel or Script window. You can also export your scripts from the Actions
panel to external ActionScript files. (When you use the Script window, exporting is unnecessary because you can
instead save the AS file.)
If text in your scripts doesn’t look as expected when you open or import a file, change the import encoding preference.
Import an external AS file
1
In the Script pane, place the insertion point where you want to locate the first line of the external script.
2
Do one of the following:
•
In the Actions panel, select Import Script from the panel menu, or press Shift+I (Windows) or
Shift+I (Macintosh).
•
In the Script window, select File
> Import Script or press Shift+I (Windows) or Shift+I
(Macintosh).
Updated 5 March 2009