Global trace in your Adobe Flex program

Ability to trace message is very important in building any complex program. 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.

<?xml version="1.0"?>
<!-- logging/ButtonLifeCycle.mxml -->
<mx:Application xmlns:mx="" creationComplete='trace(employees)'>
private function traceClick():void {
trace("Entering traceClick");
trace("Exiting traceClick");
<mx:XMLList id="employees">
<name>Christina Coenraets</name>
<name>Joanne Wall</name>
<mx:Button id="b1" label="Click Me" click="traceClick()" />

You can call trace() method from either the ActionScript or from MXML with either object or String as argument and that message will get traced to the flashlog.txt, if trace is enabled like this

Christina Coenraets

Joanne Wall

Entering traceClick
Exiting traceClick

No comments: