T-W > trace
traceSyntax
trace(
expression
);
Arguments
expression
A statement to evaluate. When you test the movie, the results of the expression
argument are displayed in the Output window.
Description
Action; evaluates the expression
and displays the results in the Output window in test-movie mode.
Use trace
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.
Player
Flash 4 or later.
Example
This example is from a game in which a draggable movie clip instance named rabbi
must be released on a specific target. A conditional statement evaluates the _droptarget
property and executes different actions depending on where rabbi
is released. The trace
action is used at the end of the script to evaluate the location of the rabbi
movie clip, and display the results in the Output window. If rabbi
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) {
rabbi.startDrag();
}
on(release) {
if(eval(_droptarget) != target) {
rabbi._x = rabbi_x;
rabbi._y = rabbi_y;
} else {
rabbi_x = rabbi._x;
rabbi_y = rabbi._y;
target = "_root.pasture";
}
trace("rabbi_y = " + rabbi_y);
trace("rabbi_x = " + rabbi_x);
stopDrag();
}