ExternalInterface not working in Firefox?

Here’s a wierd one. Let’s say you have a flash navigation – one of those old DHTML style drop-down ones, but done in flash and layered over the top of your page content. You can stick the wmode to transparent and have a transparent background for your flash.

That’s dandy – but in most browsers (ie. firefox) you’ll run into problems interacting with the content underneath your flash movie, particulary hyperlinks. Hyperlinks and form fields just become inaccessible. Setting the wmode might make things transparent, but it doesn’t help the ‘click-through’ aspect of transparency. So, what do you do? The solution I’ve been using is a JavaScript function which resizes the flash movie, activated using ExternalInterface.

The problem?

In Internet Explorer, it works fine. JavaScript calls, DOM elements resize. Firefox? No dice.

The solution.

The solution I found has prettymuch baffled me as to why it should work, but it does. Using the fully-qualified class name for ExternalInterface (flash.external.ExternalInterface) solved all of my Firefox woes.

So quite simply – change your ExternalInterface.call(); to flash.external.ExternalInterface.call();

, ,

About James

James is a Senior New Media Developer at MMT Digital, and has BA(Hons) in Design for Interactive Media from the University of Gloucestershire. He loves designing and producing all sorts of website and Flash-related things, as well as prattling on about technologies.Day-to-day he works with Flash, Dreamweaver, Director, Microsoft Office Sharepoint Server 2007 (MOSS) and in his spare time he mucks about in Flex and Wordpress.Follow James on Twitter.

26 Responses to “ExternalInterface not working in Firefox?”

  1. Tom 18th January, 2008 at 8:21 pm # Reply

    Oh thank you, that was really, really annoying. It appears to be file-specific, I use ExternalInterface all the time, even have an updated ‘traceLog’ class that automatically adds extended info and traces to both regular trace and Firebug’s console.log() in Firefox, and in this ONE file no matter what I did ExternalInterface would not work.

    All of my other files worked fine, even ones using the same exact class file (added to my main AS2 classpath). Could be something to do with the fact that this FLA was created on a Mac and published on a PC? Not likely but who knows… that’s the only difference I can think of between all of my working files and this one.

  2. James 19th January, 2008 at 5:39 pm # Reply

    I wouldn’t've thought it could be a Mac / PC issue, both of the files that caused me hassle were created and published on a PC.

    We have had separate issue with flash MovieClip loaders failing, apparently due to the hosting server being unix-based. I wonder if that has any effect on ExternalInterface?

  3. Green 15th October, 2008 at 10:54 pm # Reply

    Why the heck does this not work? Would this not be a workaround for the popup blockers.

    myClip.addEventListener(MouseEvent.CLICK, myButtonFunctionWOW);

    function myButtonFunctionWOW(event: MouseEvent) {
    flash.external.ExternalInterface.call("http://www.site.com/index.html","_blank",'height=600, width=200');
    }

  4. James 16th October, 2008 at 10:21 am # Reply

    Green – the ExternalInterface has to call an existing function in the page – I see what you’re trying to do, but you’re doing it wrong!

    The 1st variable of the call has to be the function name, and the next are the variables, I think. So what you’re trying to do is call a function named ‘http://www.site..‘ which doesn’t exist. You need to call a function that creates a new javascript window, and pass the url and target as variables to that.

    Have a look at this page.

  5. Robert 2nd February, 2009 at 3:52 pm # Reply

    Wow.. you just saved me a heap of trouble.. thanks!.. Does beg the question of WHY.. but then actionscript 2.0 always was quirky.. Will be glad when all my work gets onto 3.0

    thanks again

  6. Ed 9th February, 2009 at 3:30 am # Reply

    Thanks.

    This works perfectly!

  7. Aubrey 13th March, 2009 at 7:57 am # Reply

    I just want to confirm that this solution works. This is great, I always wondered why External Interface failed in AS2.

    Coincidentally you do not need to implement this for it to form from AS3, thanks Adobe.

    ;) My client thanks you, and so do I!

    -aubz

  8. Viktor 19th March, 2009 at 2:52 pm # Reply

    thanks man, it works

  9. Dave 23rd May, 2009 at 11:14 am # Reply

    Doesn’t work for me unfortunately… Doing flash.external.ExternalInterface.call(“alert”, “WTF?”) still does nothing. :(

  10. James 25th May, 2009 at 10:57 pm # Reply

    @Dave – have you tried creating your own javascript function in the HTML page? I’m not sure if you could call ‘native’ javascript methods via ExternalInterface – but maybe you could make your own wrapper function in javascript that would do the same thing.

    This link might help.

  11. aw 22nd June, 2009 at 9:09 am # Reply

    It’s able to call native functions. you may even call console.log if you have firebug enabled :)

  12. Nathan 1st July, 2009 at 8:05 pm # Reply

    Just tried the FF fix and I still am getting no dice with FF 3.5.

    Have you tried this is the latest FireFox 3.5?

  13. Superficial 4th September, 2009 at 3:02 pm # Reply

    After also having these problems with FF 3.5 i found out what was wrong in my case.

    When i inspected the DOM i saw that in FF using the (Adobe preffered) way of getting a pointer to the Flashfile, document[flashid] returns a NodeList when using the Prototype framework.
    This nodeList contains 2 nodes, the embed and the object tags with the id=FlashId and name=FlashName.

    I worked arround this “problem” by checking if the value that’s returned by document[FlashId] has a length attribute and when it does, take the 2nd element of that array to work with.

    This seems to work in the most popular browsers.
    Tested it in IE, FF, Chrome, Safari (PC version) and Opera

    Hope this helps anyone with the same problem.

    Greetz Superficial

  14. Jon 7th September, 2009 at 12:47 am # Reply

    Hello could you Superficial could you expand on your solution for the lest technically minded?

    thanks
    Jon

  15. Corona 15th September, 2009 at 11:57 am # Reply

    @Superficial

    You mean on the lines of this?

    http://corona.pastebin.com/m29c2a5e5

  16. Corona 15th September, 2009 at 11:58 am # Reply

    srry wrong link

    EDIT:
    http://corona.pastebin.com/d4d25a0d1

  17. Robson Waterkemper 8th December, 2009 at 3:57 pm # Reply

    I was having problems with ExternalInterface and Firefox and Chrome and discovered that the Adobe Script was not writing the Flash tag quickly enough, so when the browser tried to find the addCallback() function it was not there at the time.

    Simply putting my Javascript function that calls the Flash created addCallback() in a window.setTimeout() calling solves the problem. Delays less than 200 ms still make the problem to occur.

    I didn’t have to use the solution of trying to find if the “length” attribute exists in the document[FlashId] object. Just calling “FlashEmbed = document[FlashId]” worked just fine.

  18. James 8th December, 2009 at 4:48 pm # Reply

    Thanks for the tip, Robson – hopefully will prove useful to someone!

  19. Suraj Chandran 1st April, 2010 at 6:35 am # Reply

    I cant thank you enough. I spend hours trying to figure what the fuck is wrong. And using the fully qqualified names solves it.

    I still wonder why this solves the problem.

  20. sean 30th April, 2010 at 8:39 pm # Reply

    No man this did NOT work.

    Thank you though for trying, I wish it were this simple.

  21. Fiona Coulter 11th November, 2010 at 12:11 am # Reply

    Thanks Robson WaterKemper, the window.setTimeout() solved the problem for me. I thought that it would be on the right track because the javascript error console kept telling me that the callback function within Flash was not a function, so clearly it is not being defined quickly enough.

  22. Jason 20th November, 2010 at 2:57 pm # Reply

    My trouble is very strange. It’s always OK in IE. but it’s not OK in Firefox, when I just make the HTML file larger by adding some text in the html code.

  23. Rachael 15th July, 2011 at 3:06 pm # Reply

    Hi! This is happening currently for Firefox 5.0. I’m imprinting “flash.external.ExternalInterface” and these are my functions: //confirmation dialog
    function confirmationDialog(mesg:String) {
    return flash.external.ExternalInterface.call("confirm", mesg);
    }
    //alert dialog
    function alertDialog(mesg) {
    return flash.external.ExternalInterface.call("alert", mesg);
    }

    I’m using Actionscript 2.0 in Multimedia Flash Professional 8. Confirmations and alerts will crash in Firefox for a while, then it will be okay and work perfectly for a few hours. I haven’t experienced any problems with IE9 or Chrome. Any help would be MUCH appreciated, thanks!

  24. James 20th July, 2011 at 8:31 am # Reply

    @Rachael – I’ve found that when you’re trying to launch popup windows or confirmation windows in the external page JavaScript, it doesn’t work so well if you try to immediately launch the popup in response to a click in Flash.
    I’ve worked around this in the past by adding the click into an ActionScript Timeout, using code like:

    function alertDialog(mesg) {
    setTimeout(function() {
    flash.external.ExternalInterface.call("alert", mesg);
    }, 0);
    }

  25. Rachael 20th July, 2011 at 3:34 pm # Reply

    Thanks James! I tried that and it didn’t work..it said that there is no method with the name setTimeout. After digging around the internet, I found out that changing it to _global.setTimeout would help. So it compiled fine, but it is still crashing in FireFox, so it didn’t solve the problem.

Leave a Reply

Note: This post is over 4 years old. You may want to check later in this blog to see if there is new information relevant to your comment.