views:

85

answers:

2

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?

+2  A: 

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.

Jasconius
+1  A: 
  1. IOErrorEvent is not bubbled so you cant catch or control it if someone else is implementing it.
  2. Please find out which third party component you are using and try to get source if its open source or read some documentation or ask support guys on how to turn off this alert.

For example, if I made RSS component for flex and on error if I displayed the alert, if you use my component, whatever you can do you cant turn off my error alert unless i have provided you a boolean switch to turn it off. So this is really a problem with who has written the code for this alert box. Whatever you do you will not be able to turn this thing off. Except reverse engineer, change the code and recompile it, but it should be legal.

Akash Kava
1) Oh, bugger. Though I ought to have guessed; that's certainly consistent with the behavior I'm seeing. Thanks, it's info I didn't have before. 2) But I'm not using any third-party components. The HTML is third-party (meaning that "Feed the application HTML that sucks less" isn't really a solution), but the component that's (apparently) barfing-out the IOErrorEvent is a simple mx.controls.Text object.
BlairHippo
Clarification: technically speaking, "Feed the application HTML that sucks less" actually IS a solution, providing I perform validity checks on any URLs in that HTML and yank any that look like they're giving me trouble. But that smells very labor-intensive to me; I'm still hoping for a solution that caters to my sense of laziness.
BlairHippo
can you post code of what exactly validatiy checks you are doing on urls?
Akash Kava
I'm not doing any validity checks yet, and I'd rather not; that's my point. I'd need to attempt to load each URL and catch any errors off of that, and then set up a timer so that when the load is complete the URL can be flagged as OK. Unless I'm missing something (always possible), it sounds like a recipe for code that won't be at all pleasant to work with. I'd much rather catch the errors that are coming off the HTML rendering, but the more I investigate, the more I suspect that's not really going to be possible.
BlairHippo