Flash error capture (Catch all Exception in Flash) _flex

Source: Internet
Author: User
In Flash Player 10.1 and above, Adobe has new global error handler uncaughterrorevents. Errors that are generated anywhere in the global area can be captured at the capture and bubbling stages if they are not captured.

The Uncaughterrorevents object that dispatches the event is associated with a Loaderinfo object or Loader object. Use the following properties to access the Uncaughterrorevents instance:
Loaderinfo.uncaughterrorevents: Detects an unhandled error in code defined in the same SWF.
Loader.uncaughterrorevents: Detects an unhandled error in code defined in a SWF that is loaded by a Loader object.
If the content runs in the debugger version of the runtime, an error dialog box that is not caught will appear when an unhandled error occurs. For these runtime versions, the error dialog box still appears, even if the listener is registered for the Uncaughterror event. In this case, to prevent the dialog box from appearing, you can invoke the Preventdefault () method of the Uncaughterrorevent object.

But the flaw in this approach is that you have no idea where the errors come from, that you can't trace the source from the event, so you can't do something special with that particular message.
If your project is likely to be under version 10.1, so you'd better

Flex Code :
Copy Code code as follows:

if (Loaderinfo.hasownproperty ("uncaughterrorevents"))
{
Ieventdispatcher (loaderinfo["uncaughterrorevents"]). AddEventListener ("Uncaughterror", UncaughtErrorHandler);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.