Name

trace( ) Global Function — display a value in the Output window

Availability

Flash 4 and later

Synopsis

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.

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.

Usage

Unfortunately trace( ) can be quite slow. Turn off tracing under File Publish Settings 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 then output the expression

See Also

Chapter 19

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.