trace( ) Global Function

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
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

     
       About Safari   |   Terms of Service   |   Privacy Policy   |   Contact Us   |   Help   |   Submit a Problem
    Copyright 2002 O'Reilly & Associates, Inc. All rights reserved.
    1005 Gravenstein Highway North
    Sebastopol, CA 95472
     


    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net