While working on a few PhotoSnack albums a few days ago, I’ve tested some features with several browsers but noticed that with Internet Explorer the albums were not working as supposed to. Specifically, the ExternalInterface.call() function wasn’t calling the target JavaScript functions at all.
After testing the JavaScript and ActionScript functions separately, it seemed they all worked without any problems. Anyway, the JavaScript functions were being called with no problems on all the other browsers I tested, except on Internet Explorer. After searching the problem on the Internet I came upon a comment on the ActionScript 3 documention posted on Adobe’s livedocs for the ExternalInterface class (thanks gerdy).
It looks like for the ExternalInterface.call() function to work in IE, the embedded Flash object MUST have the id attribute specified. Otherwise you won’t be able to display not even a JavaScript alert message from Flash. As soon as the id attribute was set for the flash objects in PhotoSnack, the albums worked just fine with Internet Explorer too.
So, as a best practice, I recommend always setting the id attribute of your Flash objects embedded in HTML pages.
Pingback: negush blog » Blog Archive » ExternalInterface: Flash – JavaScript communication
Any chance you have an example of this?
thanks!
Lance
Thanks for posting this. This helped me solve a problem.
Thanks it really helps
Thank you thank you thank you :) :D
Helped very much!!
Thank you very much!!! You are 100% right! Works like a charm!
Thanks!
Can any post some sample code Pls . I am calling javascript method by clicking on the button in the flash window. I have specified the id for the button. On button click , I am calling on AS method which internally call the JS method which not happening in IE . In all other browsers its working fine .
@reddy
You should have an AS3 call to external interface like this: ExternalInterface.call(myJavascriptFunction);. Also, that javascript function should be defined on the global window object to make sure that flash player has access to it: window.myJavascriptFunction = function() { … }. And make sure that the embed code for your flash object has an attribute id=”myFlashObject”. Oh, and another thing: make sure that the javascript function is already defined when you make the call from Flash (though, usually by the time the flash object is loaded and initialized, javascript functions are also defined).