Archive for the ‘bug’ Tag

IE7 and IE8’s indexOf() Array Bug

If you try to use indexOf() to check the existence of an Array member in <IE9 the script will fail. This is because the Array class in <IE9 does not have the function indexOf() built into it. This is not amazing.

To render this problem obsolete you could use the jQuery inArray() method, although then you are dependent on jQuery being in existence –

Or, alternatively you could just add indexOf onto the Array prototype if it doesn’t exist using something like this:-

// <IE9 indexOf() fix
if (!Array.indexOf) {
  Array.prototype.indexOf = function (obj, start) {
    for (var i = (start || 0); i < this.length; i++) {
      if (this[i] == obj) {
        return i;
   return -1;


1046: Type was not found or was not a compile-time constant

This bug can happen for all sorts of reasons…… and it won’t throw up much information as to what the problem really is. In my case the reason I was seeing it was that I had my library item class named the same as the stage instance and/or the class reference to the object itself. Solution – make sure your names are different between class object, library class name and stage instance. Hopefully this may save someone out there some time…..

AS3 Debugging Help – My New Friend – getStackTrace()

This week, for my sins, I have been integrating a Flip Book component into a site I have built using the awesome Gaia Framework. Together, these two code libraries constitute tens of thousands of lines of code and I was getting some run-time errors that I found incredibly difficult to solve. The error text being thrown in the output window revealed next to nothing about where the errors were occurring. Much googling later, I came across a debugging trick that has, until now, passed me by. Basically, you can throw a stack trace in the Debug player at runtime to see exactly where code at that point is originating/firing from. Doing this helped me to instantly locate the source of my troubles. Here is the code:-

//creating but not throwing the error
var er:Error =new Error("BREAK");
// see where issue is happening, but continue running
trace("getStackTrace(): "+er.getStackTrace());

I found this useful trick here – – much thanks to Troy Gardner.

Compile Time Error – The definition is in circular inheritance

I just thought I would post this compile time error solution in the hope it saves others some time. It was basically stupidity on my part but it took me 5 minutes to see what I had done. Googling the error also brought up a number of irrelevant issues….

Basically at compile time I was getting this error – The definition is in circular inheritance – I had a library symbol linked to a class This class was a subclass of the superclass My mistake was that I hadn’t noticed that the library symbol main class in the object properties had been autonamed to Toolbar and this is what was throwing the error and causing the problems. Solution – rename the class in the library properties. Simple.

Snow Leopard issue with VMWare Fusion

So….. when I installed Snow Leopard my VMWare Boot Camp partition became inaccessible from VMWare!!! Booo! It turns out if you get the FREE upgrade from VMWare Fusion 1 to 2 the issues are cleared up. I am now back into my Windows partition.

VMWare Fusion 2 seems to have a bunch of improvements which are definitely worth checking out. I just enabled the improved DirectX 9.0 3d graphics and for the first time, enabled a shared folder that I will use as a bridge between the two OSes when needed.