Long, long ago, I posted about my old TraceManager class for supreme debugging, but it was flawed! Hans from ObjectPainters was kind enough to comment with a link to a similar project he had put together. His did not have as much sophistication in its data tracing, but it did have a “FunctionWrapper.” His FuncitonWrapper could modify existing functions in run-time (so you don’t have to) allowing his tracing capabilities to be applied to any function without requiring the programmer to modify actual class files.

Hans was right about the usefulness of a function wrapper, but I didn’t feel like getting into it . . . until now. A couple days ago I brought up my old TraceManager and decided it was time to revamp it.

//Wrap class
traceManager.wrapClass(testClass , “testClass”)
//Run class function
var diff:Number = testClass.Subtract(6 , 3 , “trace:Infinity”)

The testClass.Subtract() function above was not capable of producing sophisticated trace data until the traceManager.wrapClass modified it and every other function in the testClass class.

I’ve taken Hans’ proposal one step further, by creating a ClassWrapper (using the undocumented ASSetPropFlags) that will automatically apply tracing capabilities to all functions within a given class instance. Finally, I feel the TraceManager to be a tool that all actionscripters could use in any project:


I’ve added those 2 new functions, modified formatting a bit, and made a few other slight adjustments. If you used the previous version you probably will barely notice the differences outside of the 2 new wrapper functions. For a review on the basic ideas check out the original post. Now I give you an example of a trace out and will explain use of the new wrappers. Continue Reading…