| Building and Deploying Flex 2 Applications > Building Flex Applications > Logging > Client-side logging and debugging > Using the global trace() method | |||
You can use the debugger version of Flash Player to capture output from the global trace() method and write that output to the client log file. You can use trace() statements in any ActionScript or MXML file in your application. Because it is a global function, you are not required to import any ActionScript classes packages to use the trace() method.
The following example defines a function that logs the various stages of the Button control's startup life cycle:
<mx:Script><![CDATA[
private function traceEvent(event:Event):void {
trace(event.currentTarget + ":" + event.type);
}
]]></mx:Script>
<mx:Button id="b1" preinitialize="traceEvent(event)"
initialize="traceEvent(event)" creationComplete="traceEvent(event)"
updateComplete="traceEvent(event)"/>
The following example shows the output of this simple application:
TraceLifecycle_3.b1:Button:preinitialize TraceLifecycle_3.b1:Button:initialize TraceLifecycle_3.b1:Button:creationComplete TraceLifecycle_3.b1:Button:updateComplete TraceLifecycle_3.b1:Button:updateComplete TraceLifecycle_3.b1:Button:updateComplete
Messages that you log by using the trace() method should be Strings. If the output is not a String, use the String(...) String conversion function, or use the object's toString() method, if one is available, before you call the trace() method.
To enable tracing, you must configure the debugger version of Flash Player as described in Configuring the debugger version of Flash Player to record trace() output.
Flex 2
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/2/docs/00001532.html
Comments
sparky1962 said on Aug 26, 2006 at 5:44 AM :