Yeah, that's what I thought....  Ugh...  That means re-writing a bunch of code 
just to add a damn Yes/No choice for the user...  Not fun...  I just with the 
bosses would stop wanting stuff changed!!  LOL

L.


--- In [email protected], "Tracy Spratt" <tr...@...> wrote:
>
> ".Is there a way to stop the program's running until." No, there is no way
> to stop a function from running.  A Flex app is essentially single threaded,
> from the developers perspective.  You must have your alert box call a
> handler function, then in that function, complete whatever action you need
> based on the event.detail.
> 
>  
> 
> Tracy Spratt,
> 
> Lariat Services, development services available
> 
>   _____  
> 
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Laurence
> Sent: Sunday, February 14, 2010 10:32 PM
> To: [email protected]
> Subject: [SPAM] [flexcoders] How to stop execution?
> 
>  
> 
>   
> 
> Here's what I've got... I have an 'if' statement that calls a boolean
> function -- problem is, that function pops up a Yes/No Alert window. In
> order to know what button the user clicked, the handler-function must be
> called from the Alert pop-up, thereby preventing the boolean function from
> returning a proper value based on the outcome of the Alert window...
> 
> Lemme 'splain a bit better with an example:
> 
> private myMainFunction():void {
> //many things going on here before we get to the 'if' statement below.
> if (myBooleanFunction()) {
> //set a local-to-this-function variable here.
> } else {
> //set a local-to-this-function variable to something else.
> }
> //More things going on here that need the above-referenced
> local-to-this-function variable to be set before they can run.
> }
> 
> private function myBooleanFunction():Boolean {
> Alert.show("Do you want to do this?","Alert...",(Alert.YES | Alert.NO, this,
> alertHandler, null, Alert.NO);
> //Flex is expecting a true/false return HERE, but I can't give one because I
> don't know the result until the alertHandler has run.
> }
> 
> private function alertHandler(event:CloseEvent):void{
> if (event.detail == Alert.YES) {
> return true; //of course alertHandler isn't a boolean, so this doesn't work.
> } else {
> return false; //of course alertHandler isn't a boolean, so this doesn't
> work.
> }
> 
> Of course the above example does NOT work, because the alertHandler function
> is of type void, and the myBooleanFunction doesn't return anything. So, how
> do I get the myBooleanFunction to return true/false based on the outcome of
> the alertHandler function? Is there any way to do this? If not, what's my
> alternative? Is there a way to stop the program's running until alertHandler
> sets a public variable, perhaps? What's the proper way to handle this?
> 
> Thanks,
> Laurence MacNeill
> Mableton, Georgia, USA
>


Reply via email to