I have run into some strange behaviour in Flash and Firefox recently. We had a Flash movie (AS3) that loads up, in its document classes constructor it sets a few event handlers on loaderInfo:
this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, progress);
this.loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
this.loaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
The problem taht seemed to be happening (most of the time, ie not 100% reproducible) was that the movie was failing to fire the Event.COMPLETE event handler. After some browsing I found Marguera’s post which suggests adding another event handler, Event.INIT and pointing it at the same handler as the Event.COMPLETE event.
this.loaderInfo.addEventListener(Event.INIT, loadComplete);
Then updating the loadComplete method to check if we had actually finished loading, if so remove the event handlers and carry on setting up the movie.
private function loadComplete(e:Event):void {
if(this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal){
this.loaderInfo.removeEventListener (Event.INIT, loadComplete);
this.loaderInfo.removeEventListener (Event.COMPLETE, loadComplete);
// Finish setting up the movie
// ...
}
}
This approach fixed our issue, and hopefully this post will point anyone else seeing similar irregularities in the right direction. The Flash documentation states that the Event.INIT event is fired when:
- All properties and methods associated with the loaded object and those associated with the
LoaderInfoobject are accessible. - The constructors for all child objects have completed.
And that the init event always precedes the complete event. That wasn’t what we were seeing in practice, as our complete event was failing to fire completely. hth.
Ryan you genius! I just came across this problem doing a big load queue for Numiko 2010. Searched and got your labs entry. So it came full circle. Yeah worked fine when i tested it in Chrome. Does a funny thing in Firefox whereby if i open up a new tab the images all load in instantly. It’s as if all the Event.COMPLETE listeners get called once i browse off the page.
Anyway i hope this helps someone else other than the folks here!
Or don’t use the wmode parameter unless its neccessary in which case apply this fix
thanks for sharing.
saved me a couple of hours at that least!!!
I owe you beer.
Wow, it’s amazing how sometimes you just stumble against the perfect answer. Thanks heaps for contributing.
You wouldn’t happen to know anything about FBML Briding between JS/Flash? Basically the SWF is calling a JS function using callFBJS. It works well in all browsers, except Firefox…
If you happen to know of any known issues, give us a shout.
Cheers for your help!
Sebastian.
WOW thank you!! After a couple of hours struggling what the f*** was going on, I googled the problem and found your solution. I’m eager to try it, it must work!
Thanks!