# xref to Best Practices for Writing Scripts

# Debugging

As you work on a Macromedia Flash MX document, test it often to ensure that it plays as smoothly as possible and that it plays as expected. To test movies, you use a special version of the Flash Player whose tools let you access information that helps you optimize animations and troubleshoot ActionScript. If you use good authoring techniques in your ActionScript, your scripts will be easier to troubleshoot when something behaves unexpectedly.

Flash provides several tools for testing ActionScript in your movies:

- The Debugger shows a hierarchical display list of movie clips currently loaded in the Flash Player. Using the Debugger, you can display and modify variable and property values as the movie plays, and you can use breakpoints to stop the movie and step through ActionScript code line by line.
- The Output window displays error messages and lists of variables and objects.
- The `trace` action sends programming notes and values of expressions to the Output window.
- Exception handling (`throw`, `try..catch..finally`)

You can start writing simple scripts without knowing much about ActionScript. All you need is a goal; then it's just a matter of choosing the right actions. The best way to learn ActionScript is to create a script. You can use the Actions panel to guide you through setting up simple scripts; see Using the Actions panel. Once you're comfortable adding basic actions such as `play` and `stop` to your document, you can begin to learn more about the language. To use the full power of ActionScript, it is important to understand how the language works: the concepts, elements, and rules that the language uses to organize information and create interactive movies.This section explains the ActionScript workflow, the fundamental concepts of object-oriented scripting, Flash objects, and script flow. It also describes where scripts reside in a Flash movie.

When working in the Actions panel, you can set breakpoints in ActionScript code for use in debugging. Breakpoints pause code execution and identify variable values during testing. Breakpoints are indicated in the Actions panel by a red dot to the left of a line of code.

For more information, see Setting and removing breakpoints.