FlashRant: TypeError: Error #1006: value is not a function. *@#%!% !!

by troy on July 27, 2008

There are times when I really love flash, like the time I'm able to get something amazing done in a single day, that would take weeks to do in C++ or Java. Then like tonight, what starts out simple and should take just a few minutes, turns into an 10 hour excursion trying to figure out where a problem is, deciphering cryptic messages with no obvious relationship to what's going on. It's numerous of these experiences with flash's quirks that have resulted in me seriously contemplating becoming a monk.

Take this seemingly innocuous function:

function addTest(c:Class):void {
 
trace("addingTest ");
tests.push(c);
}

This is for a unit testing library I've developed for asynchronous tests. It neatly introspects a class for methods named a certain way and makes them into test cases. That works fine.

In the esoteric camp, trace isn't the normal trace. I override trace by making it a class variable, so I can point it to a external log (PowerFlasher's SOS) which has far better coloring, filtering, and searching than any other trace console I've seen. I do that like this earlier on.

public var trace:Function = TraceAdapter.NormalTracer();

This approach works fine everywhere, and I've been using it for months. However something about the overlap between the two cause the above error. When that's buried at the bottom of layers of code that normally works fine, it takes a long time to dig to find this needle in the heap and stack.

This is typical in much of the projects I end up with, where the issue is actually not a problem with either part but rather the interaction, making it very difficult to divide and conquer. The solution in this case, is in just that function to prohibit trace at all in that class..oddly in another almost identical class it doesn't have this issue!