Use trace statements
Use
statements in your documents to help you debug your code while authoring the
trace
FLA file. For example, by using a
statement and
loop, you can see the values of
trace
for
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
statement is an efficient way to debug your ActionScript 2.0.
trace
You can remove your
statements when you publish a SWF file, which makes minor
trace
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
Chapter 18, "Debugging Applications."
756
Best Practices and Coding Conventions for ActionScript 2.0
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?