Archive

You are currently browsing the Scott Morgan blog archives for the day Wednesday, March 28th, 2007.

Mar

28

MovieClipLoader onLoadError event does not fire in Firefox when a non-existent domain is targeted

By scott

Today at work we ran into another flash player / browser inconsistency. When using MovieClipLoader to load an external asset, the onLoadError event doesn’t fire in Firefox when trying to load an asset from a non-existent domain. In fact, the onLoadStart event doesn’t even fire. The other MovieClipLoader events don’t fire but they shouldn’t, there isn’t any progress and the load never reaches completion or initialization.If you attempt to load a non-existent asset from a valid domain the onLoadError event fires fine in Firefox. In IE and Safari the onLoadError event fires in both scenarios. These are the only browsers I tested but I would be interested in seeing what happens in the others.

So let me break it down. This code doesn’t fire the onLoadError event in Firefox. It just fails silently:

var mLoader:MovieClipLoader = new MovieClipLoader();
var mObj:Object = new Object();
mObj.onLoadError = function(ev:Object):Void {
     getURL('javascript:alert("onLoadError")');
}
mLoader.addListener(mObj);
mLoader.loadClip('http://kaljdflkasjdf.com/image.jpg', this);

However, this code and domain do fire the onLoadError event.

var mLoader:MovieClipLoader = new MovieClipLoader();
var mObj:Object = new Object();
mObj.onLoadError = function(ev:Object):Void {
     getURL('javascript:alert("onLoadError")');
}
mLoader.addListener(mObj);
mLoader.loadClip('http://www.scottgmorgan.com/image.jpg', this);

Thought I would share this knowledge with the world. Last thing I want is others pulling out as much hair as I do :)