Specifications
CHAPTER 11
236
3 When you create a target within ActionScript, call the Log classâs addTarget() method to add the new target
to the logging system. Calling the
addTarget() method is not required when you create a target in MXML. As
long as the client is using the debugger version of Flash Player and meets the requirements described in
âConfig-
uring the debugger version of Flash Player to record trace() outputâ on page 232, the messages are logged.
The following example configures a TraceTarget logging target in ActionScript:
<?xml version="1.0"?>
<!-- charts/ActionScriptTraceTarget.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initLogging();">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
import mx.logging.targets.*;
import mx.logging.*;
[Bindable]
public var myData:ArrayCollection;
private function initLogging():void {
// Create a target.
var logTarget:TraceTarget = new TraceTarget();
// Log only messages for the classes in the mx.rpc.* and
// mx.messaging packages.
logTarget.filters=["mx.rpc.*","mx.messaging.*"];
// Log all log levels.
logTarget.level = LogEventLevel.ALL;
// Add date, time, category, and log level to the output.
logTarget.includeDate = true;
logTarget.includeTime = true;
logTarget.includeCategory = true;
logTarget.includeLevel = true;
// Begin logging.
Log.addTarget(logTarget);
}
]]></mx:Script>
<!-- HTTPService is in the mx.rpc.http.* package -->
<mx:HTTPService
id="srv"
url="../assets/trace_example_data.xml"










