Flash CS4 ActionScript 3.0 Tutorial


How to View a Variable Value at a Specific Point in Flash ActionScript



Tracing is often used as a troubleshooting tool in Flash. By using the trace() statement, you can request a variable's value at a specific point in the script. The value is displayed in Flash's Output panel.


Step One

Option double-click (PC - Alt double-click) the first keyframe of a new blank document to open the ActionScript panel.

Step Two

Copy/Paste the following code to the ActionScript panel.

var totalHere:Number = 1;

totalHere +=3;


Step Three

Click the Auto Format button to format the code

Step Four

Test your movie by pressing Cmd/Return (PC - Ctrl/Enter). The Output panel should display 4.

Dissecting the Code

The first line of the code establishes a number variable named totalHere and sets its initial value to 1. The second line adds 3 to the initial value. Now totalHere equals 1 + 3 = 4. The trace() statement displays the value of totalHere in the Output window.


Shutterfly 50 Free Prints 160x600