trace( ) Global Function | Flash 4 |
display a value in the Output window |
The expression to be resolved and then displayed in the Output window. If the resolved value of value is not a string, it is converted to a string before being sent to the Output window, according to the rules described in Table 3-2 in Chapter 3.
The trace( ) function is a debugging tool used only within the Test Movie mode of the Flash authoring environment. Though unassuming in nature, trace( ) is actually one of the fundamental components of ActionScript programming; it allows us to check the value of a variable or expression at any point during the playback of a movie. Because the Output window isn't available when we're testing in a browser or the Standalone Player, use an on-screen text field to display results, as follows:
this.createTextField("debug_txt", 99999, 50, 50, 300, 200); debug_txt.border = true; debug_txt.text += "Your message here" + newline;
Alternatively, call a JavaScript alert from the Flash movie, as described at:
Multiple trace( ) statements can slow down movie playback. To view a movie at its genuine speed, turn off tracing under File Publish Settings Flash using the Omit Trace Actions option.
trace(firstName); // Output the value of firstName trace(myClip); // Output the path to myClip trace(myClip._x) // Output the x coordinate of myClip trace("hello" + " there"); // Resolve and then output the expression