Detecting which button a user pressed to dismiss an Alert dialog
Alert dialog. Now we’ll look at how to determine which button a user pressed to dismiss the dialog.
Again, the example isn’t overly complex, or amazing, but it shows how you can build some basic logic into an application where you can commit or reject an action based on a user’s feedback.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.CloseEvent; private var alert:Alert; private function showAlert():void { var text:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.nntHello World"; var title:String = "This is the title of the Alert window"; alert = Alert.show(text, title, Alert.YES | Alert.NO); alert.addEventListener(CloseEvent.CLOSE, alert_close); message.text = ""; } private function alert_close(evt:CloseEvent):void { switch (evt.detail) { case Alert.CANCEL: message.text = "You pressed `" + Alert.cancelLabel + "`."; break; case Alert.NO: message.text = "You pressed `" + Alert.noLabel + "`."; break; case Alert.OK: message.text = "You pressed `" + Alert.okLabel + "`."; break; case Alert.YES: message.text = "You pressed `" + Alert.yesLabel + "`."; break; } } ]]> </mx:Script> <mx:Button label="Alert.show()" click="showAlert();" /> <mx:Label id="message" /> </mx:Application> |
11:23 AM
|
Labels:
Flex Alert Control Samples,
Flex Controls Samples
|
This entry was posted on 11:23 AM
and is filed under
Flex Alert Control Samples
,
Flex Controls Samples
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment