Check which button click in Alert close event
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:s="library://ns.adobe.com/flex/spark"
>
<mx:Button id="showAlertButton" click="showAlert(event)" label="Alert"/>
<mx:Label id="displaySelectionLabel"/>
<mx:Script>
import mx.events.CloseEvent;
import mx.controls.Alert;
import mx.events.MenuEvent;
private function showAlert(evt:MouseEvent):void {
var alert:Alert = Alert.show("Button was clicked", "Alert Window Title", Alert.OK | Alert.CANCEL | Alert.NO | Alert.YES, this, onAlertClose);
}
private function onAlertClose(evt:CloseEvent):void {
switch (evt.detail) {
case Alert.OK:
displaySelectionLabel.text = "OK Clicked";
break;
case Alert.CANCEL:
displaySelectionLabel.text = "CANCEL Clicked";
break;
case Alert.NO:
displaySelectionLabel.text = "NO Clicked";
break;
case Alert.YES:
displaySelectionLabel.text = "YES Clicked";
break;
}
}
</mx:Script>
</mx:Application>
Related examples in the same category