You need to use preventDefault() in the confirmTabDelete function and then 
display the Alert box. Then when the user clicks ok, close the tab 
programmatically. I'm not familiar with SuperTabNavigator but normally this 
kind of events are only dispatched as a result of a user action, so when you 
close the tab programmatically the second time, this will really close it 
without going through the event handler.



private function confirmTabDelete( event:SuperTabEv ent):void {

   Alert.show(" Are you sure you want to delete this tab?", "Confirm 

delete", Alert.YES | Alert.NO, this, alertListener, null, Alert.NO);

                                event.preventDefault(); // Prevent default here

}



private function alertListener( eventObj: CloseEvent) :void {

   if (eventObj.detail= =Alert.NO) {
closeTab(); // Really close the tab here

   }

}

--
Laurent Cozic

Flash, Flex and Web Application development
http://pogopixels.com

--- On Sat, 2/21/09, lanekelly5 <lkel...@gmail.com> wrote:
From: lanekelly5 <lkel...@gmail.com>
Subject: [flexcoders] Using an Alert when handling another event?
To: flexcoders@yahoogroups.com
Date: Saturday, February 21, 2009, 10:18 PM











    
            I'm using a SuperTabNavigator control from the flexlib package.  
When 

the user clicks on the close button for a tab it fires the tabClose 

event.  I have specified a handler for this in the mxml for the 

SuperTabNavigator component:



tabClose="confirmTa bDelete(event) ;"



In the confirmTabDelete function I would like to pop up an Alert with 

YES | NO buttons.  According to the SuperTabNavigator docs I can 

cancel the delete action by calling event.preventDefaul t() within the 

confirmTabDelete function.  My problem is that the Alert box uses its 

own handler function for the YES/NO button clicks.  I'm not sure how 

that handler function can reference the event object to call 

preventDefault( ).



private function confirmTabDelete( event:SuperTabEv ent):void {

   Alert.show(" Are you sure you want to delete this tab?", "Confirm 

delete", Alert.YES | Alert.NO, this, alertListener, null, Alert.NO);

                                

}



private function alertListener( eventObj: CloseEvent) :void {

   if (eventObj.detail= =Alert.NO) {

       //Now what?  How to call preventDefault( ) on the event object 

in confirmTabDelete?

   }

}



Is the secret in the "this" which is being used as the parent for the 

Alert?  



Any help would be great.



}




 

      

    
    
        
         
        
        








        


        
        


      

Reply via email to