Flash Player 4.
trace(
expression
)
expression
An expression to evaluate. When a SWF file is opened in the Flash authoring tool (via the Test Movie command), the value of the expression
parameter is displayed in the Output window.
Nothing.
Action; evaluates the expression and displays the result in the Output window in test mode.
Use this action to record programming notes or to display messages in the Output window while testing a movie. Use the expression
parameter to check if a condition exists, or to display values in the Output window. The trace
action is similar to the alert
function in JavaScript.
You can use the Omit Trace actions command in Publish Settings to remove trace
actions from the exported SWF file.
This example is from a game in which a draggable movie clip instance named my_mc
must be released on a specific target. A conditional statement evaluates the _droptarget
property and executes different actions depending on where my_mc
is released. The trace
action is used at the end of the script to evaluate the location of the my_mc
movie clip, and display the result in the Output window. If my_mc
doesn't behave as expected (for example, if it snaps to the wrong target), the values sent to the Output window by the trace
action will help you determine the problem in the script.
on(press) {
my_mc.startDrag();
}
on(release) {
if(eval(_droptarget) != target) {
my_mc._x = my_mc_xValue;
my_mc._y = my_mc_yValue;
} else {
var my_mc_xValue = my_mc._x;
var my_mc_yValue = my_mc._y;
target = "_root.pasture";
}
trace("my_mc_xValue = " + my_mc_xValue);
trace("my_mc_xValue = " + my_mc_xValue);
stopDrag();
}