Use trace statements

Use trace statements in your documents to help you debug your code while authoring the FLA file. For example, by using a trace statement and for loop, you can see the values of variables in the Output panel, such as strings, arrays, and objects, as the following example shows:

var dayArr:Array = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
var numOfDays:Number = dayArr.length;
for (var i = 0; i<numOfDays; i++) {
    trace(i+": "+dayArr[i]);
}

This displays the following information in the Output panel:

0: sun
1: mon
2: tue
3: wed
4: thu
5: fri
6: sat

Using a trace statement is an efficient way to debug your ActionScript 2.0.

You can remove your trace statements when you publish a SWF file, which makes minor improvements to playback performance. Before you publish a SWF file, open Publish Settings and select Omit Trace Actions on the Flash tab. For more information on using a trace, see trace function in the ActionScript 2.0 Language Reference.

The Debugger tool is also useful for debugging ActionScript code. For more information, see Debugging Applications