Flex MX:HTML handling errors and loading problems

2019-07-14 08:16发布

问题:

I have a simple mx:html that load a page.. I'd like to show a popup when there is a problem loading the page...

How can I handle this event? I have not find anything useful on the web :(

回答1:

mx:html is based on htmlloader, and unfortunately you cannot read HTTP headers using this object, so you cannot read the HTTP status. Several workarounds are:

a)use an urloader before the htmlloader and check the HTTP status

b)you can read the html page content with yourhtmlcontrol.htmlloader.window.document. If it's a known page you can detect if the page content corresponds with some status.

I think that a) is more reliable than b).