Adobe Flash ExternalInterface issues with Internet Explorer

On a recent project, I was asked to build a simple Flash mp3 player that could be controlled with JavaScript by using ExternalInterface.  I built and tested the whole application in under an hour and was feeling pretty good about myself.  QA filed a bug saying that JavaScript was throwing an error, and it only occurred when my mp3 player was present.

The error only happened in IE8, so I was stuck with IE’s debugger and error messages.  The error was being thrown when the loaded SWF attempted to add callbacks to ExternalInterface using ExternalInterface.addCallback  As soon as this function was called my script threw an error:

Object doesn’t support this property or method

IE 8 Error Screen

The stack trace showed an anonymous JScript block with a function named __flash__addCallback which was throwing the error when trying to append a property to a JScript object. The debugger for this particular error looked like this.

I scoured the internet searching for solutions to this problem as I was sure it had to be something that was well documented.  I came across some solutions that appeared to work for people such as: ensure your object tag has an id, ensuring you set the type or class id on the object tag. These solutions worked for some people, but didn’t solve the problem I was having.

After a little more investigation I realized that some of my ExternalInterface calls were successful, while others were not.  I then realized that play and stop were probably reserved names for IE8 and might be the root of my problem.  I adjusted the names of the callback functions to playSong and stopSong and things started working.

This Doesn’t Work:

ExternalInterface.addCallback("play", play);
ExternalInterface.addCallback("stop", stop);

This Works:

ExternalInterface.addCallback("playSong", play);
ExternalInterface.addCallback("stopSong", stop);

The moral of the story is to avoid common names when using ExternalInterface. Play and Stop I know are reserved, and I’m sure there’s a host of others out there.

Tags: , , ,

7 Responses to “Adobe Flash ExternalInterface issues with Internet Explorer”

  1. Roman Lenko June 27, 2011 at 5:13 pm #

    BLESS TO YOU!! :)

    What a stupid problem, at last! I spend few hours for finding solution and it’s all about f*cking Microsoft RESERVED names “play” and “stop”!

    Maybe they’ll reserv names “browser”, “flash” etc. or ALL common names?!!

    This was the MOST stupid problem in my life :)

    Thanks again,
    Roman.

    • boushley June 27, 2011 at 5:36 pm #

      I agree entirely. It was a pain to try and track this bug down. Once I finally figured out that it was related to the name I was pretty frustrated. Fitting to get this comment today as I stumbled upon this image http://alt-tab.org/?post/2687

      Glad I could help Roman.

  2. David Nguyen November 7, 2011 at 1:47 pm #

    So someone who is not so familiar with flex SDK and flash, how did you fix the issue? Which files to modify? I am using jquery DataTables and its TableTools set and i run accross this error.
    Thanks

  3. Joe February 19, 2012 at 1:58 pm #

    There are other words that won’t work.

    We have had exactly the same issue with ‘zoom’ & ‘pan’. Everything was fine after they were renamed. Other people also report ‘stop’ as a reserved keyword.

    There doesn’t seem to be a definitive list of these words anywhere. Hope this helps someone else!

  4. Warren June 12, 2012 at 5:21 pm #

    You just saved my life. This browser is a real pain in the ass. Thanks a lot.

  5. adhavan February 11, 2014 at 6:31 am #

    Hi,

    I load flash content with jquery,

    In IE i can’t able to get htmlembedelemt but ts orking fine in other(chrome,firefox,safori) browser.

    give any ideo to get htmlembedelemt in IE browser

Trackbacks/Pingbacks

  1. Tweets that mention Adobe Flash ExternalInterface issues with Internet Explorer | ZaaLabs -- Topsy.com - January 11, 2011

    [...] This post was mentioned on Twitter by Nate Beck. Nate Beck said: RT @zaalabs: Just Blogged: Adobe Flash ExternalInterface issues with Internet Explorer http://goo.gl/fb/RIPfd [...]

Leave a Reply