When setting the .location property of an HTML control, it is possible to set it to an invalid URL with no error. How can I determine if the change in location resulted in the loading of some HTML, or if the URL is 404?
<mx:HTML width="100%"
height="100%"
complete="Complete(event);"
location="http://qqq.xxx35627396.zzz"
id="Ghost"/>
No error is produced from the phony location shown above.
How can I detect the IOError event on an HTML control?
Thanks In Advance.
Now that I understand the question better, you’re going to want to take a look at the
HTMLLoaderobject inside the html control, probably more specifically, theloaderInfoproperty. I know the compiler thinks it isn’t there, but it is and it’s accessible.You’re going to want to attach some events to this. Here are the events dispatched by loaderInfo:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/LoaderInfo.html
This includes
as well as
Now, that said, the HTMLLoader is part of the player so you don’t have access to inspect what is happening in there or easily sub class it. So, you might run into the following issues that you’ll need to work through:
When to attach the listeners. It looks like there is only one html loader control ever created, so at least you only need to do it once (as opposed to it creating a new one to attach events to when loc changes etc)
You may not get the http_status or io_error events on invalid either. In which case, you should sniff the open and progress, if they don’t update after X amount of time, you notify the user that the address is invalid or there is a network error.
Let me know how it goes 🙂