I am trying to build some error-trapping and handling into my code.
I’m loading a series of images from an XML file. I’ve purposely entered a number of bad url’s. When I run this code, only the first IO_Error event gets caught. The second time the loader gets a bad URL, nothing happens. I mean: nothing happens.
private static function loadImage(p_url:String):Loader
{
var imageLoader:Loader = new Loader;
var myRequest:URLRequest = new URLRequest(p_url);
imageLoader.load (myRequest);
updateLoadingProgress(0x330000);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, imageLoadError);
trace ("now loading: " + p_url);
return imageLoader
}
private static function imageLoadError(evt:Event):void
{
trace ("That's not a good cookie");
getNextImage()
}
private static function getNextImage():void
{
imageIndex++;
if (imageIndex < imageList.length)
{
trace ("incoming");
// Load the next image
imageList[imageIndex][1] = loadImage(imageList[imageIndex][0]);
}
else
{
setupDisplay();
}
}
What … am I doing wrong?