Avg. Rating 2.8

Problem

Issue is in Application is throwing an error when using Alert control with not predefined buttons, for example YES and NO buttons on my alert dialog with default Alert control initialization.

Solution

When calling Alert control with not predefined buttons, you should set the defaultButton manually.

Detailed explanation

By default Alert controll have defaultButton set to 0x0004 (Button OK). But when you will use differen buttons in Alert control (all exept button OK, for example YES and NO) you will have an error:

TypeError: Error #2007: Parameter source must be non-null.
at flash.accessibility::Accessibility$/sendEvent()
at mx.accessibility::AlertAccImpl/mx.accessibility:AlertAccImpl:
:eventHandler()
at flash.events::EventDispatcher/flash.events:EventDispatcher:
:dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/::doPhasedInstantiation()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/::callLaterDispatcher2()
at mx.core::UIComponent/::callLaterDispatcher()

To avoid this error you must set the Alert.defaultButton property with button code from your set of buttons.

This is an example of calling Alert control with error in IE:

Alert.show( "Some text", "Some title", (Alert.YES | Alert.NO), null, alertHandler, null );

This is an example with correct calling of Alert control with different buttons set (0x001 is the YES button):

Alert.show( "Some text", "Some title", (Alert.YES | Alert.NO), null, alertHandler, null, 0x0001 );

Report abuse

Related recipes