User Guide
139
CHAPTER 4
Writing and Debugging Scripts
Adding scripts to your Flash applications enables rich functionality. In Macromedia Flash MX
2004 and Macromedia Flash MX Professional 2004, you have two choices:
• You can write scripts that are embedded in your Flash document (FLA file). To write
embedded scripts, you use the Actions panel and attach your scripts to a button, movie clip, or
frame in the Timeline (see “Controlling when ActionScript runs” on page 140).
• You can write scripts that are stored externally on your computer. External scripts are run when
the scripts are called in your FLA file. To write external script files, you can use any text editor
or code editor.
In Flash Professional, you can also use the Script window. For more information, see “Using
the Actions panel and Script window” on page 140.
When you use the Actions panel or the Script window to write scripts, the ActionScript editor lets
you check syntax for errors, automatically format code, and use code hints to help you complete
syntax. In addition, the punctuation balance feature helps you pair parentheses [()], braces ({}), or
brackets ([]). For more information, see “Using the ActionScript editor” on page 144.
As you work on a document, test it often to ensure that it plays as smoothly as possible and as
expected. You can use the Bandwidth Profiler to simulate how your document will appear at
different connection speeds (see “Testing document download performance” in Using Flash
Help). To test your scripts, you use a special debugging version of Flash Player that helps
troubleshooting. If you use good authoring techniques in your ActionScript, your scripts will be
easier to troubleshoot when something behaves unexpectedly. For more information, see
“Debugging your scripts” on page 153.
If you are writing ActionScript 2.0 clas
s files, see Chapter 10, “Creating Custom Classes with
ActionScript 2.0,” on page 247.