But I need to use the evt parameter in the testFunction, depending on what the user has selected in the alert.show function.
How would I reference the same from the alertHandler? I need your help. I think my understanding of the code execution in Flex is different from the norm. By the way, here's a quick example: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"layout="vertical" creationComplete="creationCompleteHandler();"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.DragEvent; import mx.events.CloseEvent; private var _alertVal:int; private function creationCompleteHandler():void { srclist.dataProvider = ['Angel', 'Bart', 'Calvin', 'Dante', 'Erich', 'Fox', 'Gale', 'Helen']; destlist.dataProvider = []; } private function destlist_dragDropHandler(evt:DragEvent):void { _alertVal = 0; Alert.show('Proceed', 'Title', Alert.YES | Alert.NO, null, handleAlert, null, Alert.YES); if(_alertVal == -1) { evt.preventDefault(); // but the above is not triggered since the code jumps already to the next line!!! } Alert.show(String(_alertVal), 'This Should Be Triggered After the Alert!!'); } private function handleAlert(evt:CloseEvent):void { if (evt.detail == Alert.YES) { _alertVal = 1; } else { _alertVal = -1; } } ]]> </mx:Script> <mx:Panel title="Select Names" layout="horizontal"> <mx:VBox width="50%"> <mx:Label text="Names"/> <mx:List id="srclist" width="100%" height="400" allowMultipleSelection="false" dragEnabled="true" /> </mx:VBox> <mx:VBox width="50%"> <mx:Label text="People Selected"/> <!-- Drop target --> <mx:List id="destlist" width="100%" height="400" dropEnabled="true" dragDrop="destlist_dragDropHandler(event)" /> </mx:VBox> </mx:Panel> </mx:Application> Thanks and regards, Angelo ________________________________ From: Beau Scott <[email protected]> To: [email protected] Sent: Thursday, 27 August, 2009 0:32:02 Subject: Re: [flexcoders] Question on Flex Script Execution + Alert.show Alert.show is async, so move the code after Alert.show to the alertHandler method after your if/else block that's already in there. Beau On Wed, Aug 26, 2009 at 12:03 AM, Angelo Anolin <angelo_anolin@ yahoo.com> wrote: > >Hi FlexCoders, > >This has puzzled me a bit.. > >I have the following scripts in my application: > >private var myAlert:int; > >private function testFunction( evt:Event) :void >{ > Alert.show('do you want to proceed', 'Title', Alert.YES | Alert.NO, null, > alertHandler, null, Alert.YES); > >> if(myAlert == 1) > { > // Do Something here > } > else > { > // Do other thing here > } >} > >Private function alertHandler( evt:CloseEvent) >{ > if(evt.Detail == Alert.YES) > { >> myAlert = 1; > } > else > { > myAlert = -1; > } >} > >Now, what puzzles me is that the script after the > Alert.show is triggered, the scripts following it are also triggered. > >Is there a way to ensure that the script following the Alert.show alert box >would only be executed after the Yes or No buttons has been pressed? > >I won't be able to move the scripts after the Alert.show script to the >alertHandler event since there are some objects being set / modified prior to >the alert being called. > >Inputs highly appreciated. > >>Thanks. > > > -- Beau D. Scott Software Engineer

