/** * Alert control provided by flex sdk is not supportted to carry data in close handler, only a predefined closeEvent object,</br> * you can use DataCarriableAlert to resolve this problem, you can obtain both the closeEvent object and your parameters. * Usage example:</br> * DataCarriableAlert.show("Are you sure to delete the selected trades?","Message",Alert.YES|Alert.NO,this,deletionConfirm,[2]);</br> * * </br>private function deletionConfirm(e:CloseEvent,intv:int):void{</br> * //intv is 2 which was passed by above code</br> * if(e.detail==Alert.NO){</br> * return;</br> * }</br> * }</br> */ public class DataCarriableAlert extends Alert { public function DataCarriableAlert() { super(); }
if (!parent) { var sm:ISystemManager = ISystemManager(FlexGlobals.topLevelApplication.systemManager); // no types so no dependencies var mp:Object = sm.getImplementation("mx.managers.IMarshallPlanSystemManager"); if (mp && mp.useSWFBridge()) parent = Sprite(sm.getSandboxRoot()); else parent = Sprite(FlexGlobals.topLevelApplication); }
/********************************override part start****************************************************************/ if (closeHandler != null){ alert.addEventListener(CloseEvent.CLOSE, function(closeEvent:CloseEvent):void{ var parameters:Array=[]; parameters.push(closeEvent); if(closeHandlerParameters!=null && closeHandlerParameters.length>0){ for each(var p:Object in closeHandlerParameters){ parameters.push(p); } } closeHandler.apply(alert,parameters); } ) } /********************************override part end*******************************************************************/
// Setting a module factory allows the correct embedded font to be found. if (moduleFactory) alert.moduleFactory = moduleFactory; else if (parent is IFlexModule) alert.moduleFactory = IFlexModule(parent).moduleFactory; else { if (parent is IFlexModuleFactory) alert.moduleFactory = IFlexModuleFactory(parent); else alert.moduleFactory = FlexGlobals.topLevelApplication.moduleFactory;
// also set document if parent isn't a UIComponent if (!parent is UIComponent) alert.document = FlexGlobals.topLevelApplication.document; }
private static function static_creationCompleteHandler(event:FlexEvent):void { if (event.target is IFlexDisplayObject && event.eventPhase == EventPhase.AT_TARGET) { var alert:Alert = Alert(event.target); alert.removeEventListener(FlexEvent.CREATION_COMPLETE, static_creationCompleteHandler);