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);
}
}

