Table of Contents

trace( ) Global Function Flash 4

display a value in the Output window
trace(value)

Arguments

value

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.

Description

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:

http://www.moock.org/asdg/technotes/traceInBrowser

Usage

Multiple trace( ) statements can slow down movie playback. To view a movie at its genuine speed, turn off tracing under File figs/U2192.gif Publish Settings figs/U2192.gif Flash using the Omit Trace Actions option.

Example

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

See Also

Object.watch( ); Chapter 17


Table of Contents