R – IOErrorEvent Eluding Capture


I'm working on a Flex application that processes and displays small amounts of HTML, sometimes including images. I'm getting the HTML out of third-party RSS feeds. Sometimes, I see this in a pop-up window:

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

The RSS URL is just fine, but there's apparently something in the downloaded HTML that's causing a problem. Since the application is meant to run as part of a non-interactive digital sign, anything that requires a click to continue is completely unacceptable. I don't care how useless or malformed a URL is; the app needs to ignore the problem without pestering the user.

Unfortunately, I'm having no luck trapping this event. I'm sprinkling calls like this liberally through the code:

[object].addEventListener(IOErrorEvent.IO_ERROR, handleIOError);

… where [object] is everything from the mx:Text object rendering the HTML to its mx:Canvas parent to the mx:Application top-level app, and handleIOError is a simple function that looks like this:

         private function handleIOError(event:IOErrorEvent):void {
            trace ("IO error occurred: " + event);

But so far, nothing; that bloody error keeps popping up in the Flash player. Does anybody have any insight as to where I'm going wrong?

Best Solution

Make sure you are putting the event on the right object. I haven't done a whole lot of remote loading in Flex, but in Flash, a hilarious and annoying quirk is that when you use the Loader class to load images, the object you need to put event handlers on is NOT the Loader itself, but a property of the loader called contentLoaderInfo.

Read the docs carefully on the objects you are using, a similar pitfall might be at play.