IE7 and IE8 both have serious issues with regard to <object> based embedding of Flash when utilizing the ExternalInterface.addCallback function. When embedding a SWF using this method, you may (and probably will) run into issues when leaving or reloading the page, which will throw up an “Object doesn’t support this property or method” error. This error will pop up for every single ExternalInterface.addCallback you add in your code.

This is happening because the “id” and “type” tags are probably not defined in your <object> code. Here are some examples:

This will throw an error when trying to unload the SWF:

<object height=”400″ width=”300″> … embed code here … </object>

This will not throw an error:

<object height=”400″ width=”300″ id=”current_embed” type=”application/x-shockwave-flash”> … embed code here … </object>

But what if you made an awesome widget already, and there’s a billion people already embedding it with the old code? That’s exactly what happened to us at Current, so the only fix that works for us must come from within the Flash (because we have the ability to replace it for everyone). To fix this we had to find the root of why IE was failing, and it was doing so because it was trying to map the external interface calls using the HTML defined ID, rather than an internally generated one (which I presume is how all other browsers do it). You will have a hard time controlling a SWF through Javascript if it doesn’t have an ID anyways, so I think MS assumed that anyone who used ExternalInterface.addCallback would also be defining an ID for it.

Luckily, Actionscript has a little known property in it’s ExternalInterface object called objectID. If the <object> is not declared correctly, this property will be null. So the solution is quite simple, check to see if it’s null before adding any callbacks. The code looks like this (AS3):

if(ExternalInterface.available&&ExternalInterface.objectID!=null)

{

ExternalInterface.addCallback(”myFunc”,_myFunc);

}

This will fix the issue, however please note that you won’t actually have any methods available to you in your Javascript code if you were identifying it through the name attribute instead.

Yet another crappy thing to deal with in IE.