dagobert_renouf
asked on
Javascript call to swf function (using the as3 externalInterface API) not working 100% of the time
Hello,
I created an AS3 swf module which, from a javascript call, load and image into a movieclip for further transformation.
I ran it under ff3 and ie6/7 hundreds of time with no issue, but when I tried to test it under opera, I encountered some problems :
Sometimes the page loads but the javascript flashcall doesn't fire (javascript function fires but not the flashcall in it), so my image doesn't load in the swf file ! If I hit refresh on the page : one time it is on, one time it is off.
The bug also appear on ff and opera when I "go back" to this page (I'm browsing the website, going one page further and then do "previous page").
_____
The javascript function I call on page load is : "thisMovie("productviewer" ).loadImag e(image)" and when firefox/opera decide not to show my image : the error console tells me that "thisMovie("productviewer" ).loadImag e is not a function".
How do I make it work ?
I created an AS3 swf module which, from a javascript call, load and image into a movieclip for further transformation.
I ran it under ff3 and ie6/7 hundreds of time with no issue, but when I tried to test it under opera, I encountered some problems :
Sometimes the page loads but the javascript flashcall doesn't fire (javascript function fires but not the flashcall in it), so my image doesn't load in the swf file ! If I hit refresh on the page : one time it is on, one time it is off.
The bug also appear on ff and opera when I "go back" to this page (I'm browsing the website, going one page further and then do "previous page").
_____
The javascript function I call on page load is : "thisMovie("productviewer"
How do I make it work ?
// Javascript functions
function thisMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return document[movieName];
}
function stickerInitiate(image){
thisMovie("productviewer").loadImage(image);
}
// Html call (based on mootools)
window.addEvent('load', function() {
stickerInitiate(myimage);
});
ASKER
This solution allow firefox to work everytime, which is good.
However my main issue is with opera (25% of my users), and it's still not working with that solution.
However my main issue is with opera (25% of my users), and it's still not working with that solution.
Ok, I am only skimming things quickly so I apologise for not testing that out (I was more than half scared the issue was to do with the swf so wasn't sure I could test it for you).
If you instead have a look at this example
http://arieslink.sitebar.org/onload-1.html
this seems to be running a pretty bomb proof piece of code the discussion about this topic has been running here for years and this is their latest effort. Hope that helps. If this is over the top then just consider
window.addEventListener('D OMContentL oaded', init, false);
which should work for both FF and Opera.
If you instead have a look at this example
http://arieslink.sitebar.org/onload-1.html
this seems to be running a pretty bomb proof piece of code the discussion about this topic has been running here for years and this is their latest effort. Hope that helps. If this is over the top then just consider
window.addEventListener('D
which should work for both FF and Opera.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The snippet below should give you a hint.
Open in new window