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

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!

{ 15 comments… read them below or add one }

Symba October 21, 2008 at 5:15 pm

I had the same error, and struggled to fix it four 2 hours. The problem in my case was that I put ‘()’ to a property ( numChildren() instead of numChildren ). The motherF$#@s gave me shitty error message. By accident I found it ( I was lucky after ‘only’ 2 hours, but it could have been 10 hours – like your case). Please keep posting this kind of articles because it could save someone 10 hours of searching the needle.

Wish you the best,

demha June 15, 2009 at 11:50 am

thanks symba… I’m looking for hours and i not see my error. I do the same error… data() instead of data= and this error message dont help me…

AJ June 24, 2009 at 12:25 am

This comment is pretty late, but I just wanted to leave some help for anybody else who finds this post when searching for this error. In my case I got the error because my code was referencing a CSS class that wasn’t declared.

ActionScript parses your CSS to build the look/feel of display objects, and if you reference something in CSS that isn’t defined or available…boom.

Jonathan August 10, 2009 at 10:14 am

If you haven’t figured this one out already, it has to do with the \()\ after \NormalTracer\. When assigning functions to a variable (or registering callback funcsions in event handlers), you don’t add the \()\ after the function name. This will actually execute the function instead of assign it to your variable. This would work if \NormalTracer\ actually returned a function reference, but I’m guessing that it returns \void\, not a function. Hence the error message- value (returned from function call) is not a function. It’s a common mistake. I’ve struggled with it in the past as well.

troy August 11, 2009 at 3:27 pm

Thanks Jonathan for the great response
I totally know what you mean, use that sort of callbacks as well. I think in this case NormalTracer might have been a get function returning a reference to the real trace function built into flash. So a function call returning a function.

So what likely is the issue is a static initialization in most cases this works but something about the dependencies on this one can be sent up so it failed.

kim August 13, 2009 at 1:50 pm

Thanks for saving me two hours, or ten hours, of searching. These cryptic and vague error messages can be a nightmare. In my case, it was using length() for an array, instead of length… I’d used length() earlier in the code for an XML call and typed it again without realizing.

Peter August 19, 2009 at 3:31 am

I got this error in a for loop where I forgot to use the index on the array.
I used someArray.someFunction(); instead of someArrayt[i].someFunction();

Sebastian September 4, 2009 at 5:43 pm

Thanks Peter, for the hint. You could use the following instead, as it works for me now.
for each (var item in someArray){

Eva December 9, 2009 at 8:46 pm

I’m dealing with this error, and have no ideia how to resolve it.

I have a function

function onConfigXMLLoadMain(event:Event):void {//config.xml loaded
var configXMLMain:XML = new XML(event.target.data);
configXMLMain.ignoreWhitespace = true;


and a XML file loaded like this.

var configXMLLoaderMain:URLLoader = new URLLoader();
configXMLLoaderMain.addEventListener(Event.COMPLETE, onConfigXMLLoadMain, false, 0, true);
configXMLLoaderMain.load(new URLRequest(“config.xml”));//load config from config.xml

But then the error occurs…

I’m not an expert in programming, but i think you can have an insight of what might be happening..

Thank you

troy December 9, 2009 at 9:22 pm

Hi Eva,

Aside from the quotes in your example ( ”) you code worked fine for me., your error is someplace else in the code. Try commenting or cutting out parts of the code and republishing till you find the break.

Also I’m not unfortunately not in a position to support more (school, work etc)

Good luck


Gohar Sultan January 2, 2010 at 6:27 pm

I have found the problem with Error 1006 in Action Script 3

following statement return error


and if i write this statement as


it works fine :)

i guess its some problem with actionscript compiler…

i hope it works for you


Maurycy Zarzycki January 8, 2010 at 7:29 am

In case anyone is working with Flash and exports stuff from library to ActionScript, remember to target the good package. I had class src.ContentMovie, but in the object’s “Export For ActionScript->Class:” I had ContentMovie. And the code all over the place thought I was refererring to the ContentMovie, not the src.ContentMovie. Luckily took me less than 20 minutes to find.

Mark A. January 14, 2010 at 12:43 pm

The problem can occur when dealing with linkage in your library. I started with linking an asset with a class name of “NaviItem” but without a real class built at that moment. Over the time the NavItem was getting more advanced in functionality so I had to write a class for it. The problem arouse when I tried to call some functions I had just defined in the class. I missed to correct the linkage of the symbol to the right class. Pay attention to that!

Bregje January 2, 2012 at 7:39 am

I have a problem and I’m looking for hours and it is driving me crazy. I have also an error #1006 but I really can’t find out why!

I have two scrollPane components and one of them, the first, is working without any problems but that other one (this one has an other name & is in another scene) isn’t working properly and gives me that irritating error! The setSize isn’t a funcion or something like that.

PLEASE HELP ME! – Almost crying at this point.

My code:

ScrollPane02.source = tekst03;
ScrollPane02.move(0, 20);
ScrollPane02.scrollDrag = false;

THNX in advance!

troy January 2, 2012 at 8:12 am

Just start adding trace statements to figure out what’s breaking at what specific time. e.g. trace(“ScrollPane02.source”, ScrollPane02, ScrollPane02.source);

Else you may need to wait a frame, so things can be fully ready to be called. After you go to another scene, just wait a frame before you use anything on it.

That’s all I can help with, we all have our own dragons to slay.

Leave a Comment


Previous post:

Next post: