PDA

View Full Version : Help handling URLloader error



Shaedo
May 31st, 2009, 02:45 PM
Hi I am trying to implement some error handling into my code.
[/URL]
I am still getting the error:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

I want to be able to feed invalid URLs into the loader without it causeing a problem.

Here is the relevant (?) extract of my code:


{
var image_url = kanaImages[imageCount].@IMAGE;
image_loader = new Loader();
image_loader.addEventListener(IOErrorEvent.IO_ERRO R, catchIOError);
image_loader.load(new URLRequest(image_url));
image_loader.contentLoaderInfo.addEventListener(Ev ent.COMPLETE, imageLoaded);
}

private function catchIOError(event:IOErrorEvent)
{
trace("Error caught: "+event.type); // this never gets triggered.
}

This works fine with valid URLs.

I was trying to do as Senocular describes here:
[URL="http://www.kirupa.com/forum/showthread.php?p=1957523"]http://www.kirupa.com/forum/showthread.php?p=1957523 (http://www.kirupa.com/forum/showthread.php?p=1957523)

Thank you for taking the time to look at this problem!

S.

Shaedo
May 31st, 2009, 02:55 PM
In Senoculars example he is using type URLLoader where as I am using type Loader will that make a difference to the way I should handle invalid URLs ? (I am loading jpg images so I cant use the URLLoader....)

cbeech
May 31st, 2009, 04:59 PM
naw :) URLLoader is for data - Loader is for image/swf formats - however URLLoader has a different set of event handlers that you target the instance directly.

problem is here that you need to add the IO event listener to the contentLoaderInfo prop of the Loader ;)