The UncaughtErrorEvents class provides a way to receive uncaught error events. An instance of this class dispatches an uncaughtError event when a runtime error occurs and the error isn't detected and handled in your code. Use the following properties to access an UncaughtErrorEvents instance:

To catch an error directly and prevent an uncaught error event, do the following:

  • Use a <a href="../../statements.html#try..catch..finally">try..catch</a> block to isolate code that potentially throws a synchronous error
  • When performing an operation that dispatches an event when an error occurs, register a listener for that error event

If the content loaded by a Loader object is an AVM1 (ActionScript 2) SWF file, uncaught errors in the AVM1 SWF file do not result in an uncaughtError event. In addition, JavaScript errors in HTML content loaded in an HTMLLoader object (including a Flex HTML control) do not result in an uncaughtError event.

Events:

uncaughtError

Dispatched when an error occurs and developer code doesn't detect and handle the error.

Constructor

new()

Creates an UncaughtErrorEvents instance. Developer code shouldn't create UncaughtErrorEvents instances directly. To access an UncaughtErrorEvents object, use one of the following properties: LoaderInfo.uncaughtErrorEvents: to detect uncaught errors in code defined in the same SWF. Loader.uncaughtErrorEvents: to detect uncaught errors in code defined in the SWF loaded by a Loader object.

Methods

Inherited Variables

Inherited Methods

Defined by EventDispatcher

dispatchEvent(event:Event):Bool

Dispatches an event into the event flow. The event target is the EventDispatcher object upon which the dispatchEvent() method is called.

Parameters:

event

The Event object that is dispatched into the event flow. If the event is being redispatched, a clone of the event is created automatically. After an event is dispatched, its target property cannot be changed, so you must create a new copy of the event for redispatching to work.

Returns:

A value of true if the event was successfully dispatched. A value of false indicates failure or that preventDefault() was called on the event.

Throws:

Error

The event dispatch recursion limit has been reached.

hasEventListener(type:String):Bool

Checks whether the EventDispatcher object has any listeners registered for a specific type of event. This allows you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. To determine whether a specific event type actually triggers an event listener, use willTrigger().

The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter.

When hasEventListener() is called from a LoaderInfo object, only the listeners that the caller can access are considered.

Parameters:

type

The type of event.

Returns:

A value of true if a listener of the specified type is registered; false otherwise.

toString():String

willTrigger(type:String):Bool

Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. This method returns true if an event listener is triggered during any phase of the event flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants.

The difference between the hasEventListener() and the willTrigger() methods is that hasEventListener() examines only the object to which it belongs, whereas the willTrigger() method examines the entire event flow for the event specified by the type parameter.

When willTrigger() is called from a LoaderInfo object, only the listeners that the caller can access are considered.

Parameters:

type

The type of event.

Returns:

A value of true if a listener of the specified type will be triggered; false otherwise.