756
Best Practices and Coding Conventions for ActionScript 2.0
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
Chapter 18, “Debugging Applications.”
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...