Back in May, Jesse Warden published a class that uses the TRACE function provided by the MTASC compiler to make nicely formatted output for Flashout: FAME Chronicles #2: TRACE (not trace) in MTASC.
I greeted MTASC and swfmill with open arms and cast flowers at their feet for liberating me from the Flash IDE, and I’m now a happy resident of the No-FLA Zone. I’m not a fan of IDEs in general, and I’m comfortable with my old-fashioned tools make, vi, and cvs. I especially do not want colored keywords or code completion in an editor. So I’m not feeling like jumping into FAMES just yet (or FLAMES either!).
Anyway, I’ve just gotten around to configuring AdminTool for my environment (thanks Chris and John for the good work making it compatible with MTASC!), and I expect to be using it regularly, but for simple trace output I’ve been quite happy with Keith Peters’ Flash Debug Panel. So I’ve modified Jesse’s class a bit so I can use it with the Debug Panel, thus simplifying the Debug Panel’s API as well as getting the extra debugging info that TRACE provides.
Here’s Keith’s documentation for the Debug Panel API:
Debug.trace("hello world"); // any type
Debug.trace(value1, "hello", _root); // any types separated by commas
Debug.traceObject(myComponent, n); // n is how many levels deep the trace will iterate
Debug.clear(); // clears the panel
Using my Tracer class, I’m able to say
TRACE("hello world"); // any type
TRACE(value1, "hello", _root); // any types separated by commas
TRACE(myComponent, n); // n is how many levels deep the trace will iterate
and my Tracer.coolTrace() method (kept Jesse’s name for it) figures out whether to call Debug.trace() or Debug.traceObject().
Here’s my Tracer:
class com.nodename.utils.Tracer
{
static var version:String = "$Id: Tracer.as,v 1.1.1.1 2005/07/18 00:36:48 ashaw Exp $";
static public function coolTrace(str):Void
{
if (str instanceof Object)
{
objectTrace.apply(Tracer, arguments);
}
else
{
stringTrace.apply(Tracer, arguments);
}
}
static public function objectTrace(str:Object,
depth:Number,
classNameAndMethod:String,
fileName:String,
lineNumber:Number):Void
{
var theString:String = "*****\t" + classNameAndMethod;
theString += "::" + lineNumber + "\t*****\n";
Debug.trace(theString);
Debug.traceObject(str, depth);
}
static public function stringTrace(str:String,
classNameAndMethod:String,
fileName:String,
lineNumber:Number):Void
{
var theString:String = "*****\t" + classNameAndMethod;
theString += "::" + lineNumber + "\t*****";
Debug.trace(theString);
Debug.trace(str);
}
}



Cool, someone’s using my tracer! I’ve grown pretty fond of it myself for simple tracing. Might add some features to it like remembering its size and position between runs.
Comment by Keith Peters — July 18, 2005 @ 7:30 pm
Awesome work on all this!
I don’t know ifyou’re on the osflash.org list, but I had been working to load external tools into the admintool just for this reason (someone likes using FLashInspector instead of the admintool’s logger, but they like the other features/tools of the admintool)
Here’s a quick demo I did with Pablo’s FlashInspector and loading it as an external plugin with the admintool:
http://acmewebworks.typepad.com/admintool/videos/AdminTool_plugins/FlashInspector_plugin.html
I’m hoping to get the external loading features out within this month and would love your feedback using it with Keiths logger.
Let me know what you think,
John
Comment by John Grden — July 18, 2005 @ 8:53 pm