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);
}