1. <?xml version="1.0" encoding="utf-8"?>
2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
3. <mx:Style>
4. Application{fontSize:12px;}
5. </mx:Style>
6. <mx:Script>
7. <![CDATA[
8. import mx.controls.Alert;
9. import flash.events.MouseEvent;
10. import mx.events.CloseEvent;
11. internal function initApp():void{
12. btn.addEventListener(MouseEvent.CLICK,handler);
13. }
14. internal function handler(evt:MouseEvent):void{
15. Alert.show("这是一个对话框","提示消息",Alert.YES | Alert.NO | Alert.OK | Alert.CANCEL,this,onAlertClose);
16. }
17. internal function onAlertClose(evt:CloseEvent):void{
18. switch (evt.detail){
19. case Alert.OK :
20. status.text = '你单击的是OK'
21. break;
22. case Alert.CANCEL :
23. status.text = '你单击的是CANCEL'
24. break;
25. case Alert.YES :
26. status.text = '你单击的是YES'
27. break;
28. case Alert.NO :
29. status.text = '你单击的是NO'
30. break;
31.
32. }
33. }
34. ]]>
35. </mx:Script>
36. <mx:Button id="btn" x="10" y="38" label="点击这里" width="100" />
37. <mx:Label id="status" x="10" y="10" text="" width="105" />
38. </mx:Application>
2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
3. <mx:Style>
4. Application{fontSize:12px;}
5. </mx:Style>
6. <mx:Script>
7. <![CDATA[
8. import mx.controls.Alert;
9. import flash.events.MouseEvent;
10. import mx.events.CloseEvent;
11. internal function initApp():void{
12. btn.addEventListener(MouseEvent.CLICK,handler);
13. }
14. internal function handler(evt:MouseEvent):void{
15. Alert.show("这是一个对话框","提示消息",Alert.YES | Alert.NO | Alert.OK | Alert.CANCEL,this,onAlertClose);
16. }
17. internal function onAlertClose(evt:CloseEvent):void{
18. switch (evt.detail){
19. case Alert.OK :
20. status.text = '你单击的是OK'
21. break;
22. case Alert.CANCEL :
23. status.text = '你单击的是CANCEL'
24. break;
25. case Alert.YES :
26. status.text = '你单击的是YES'
27. break;
28. case Alert.NO :
29. status.text = '你单击的是NO'
30. break;
31.
32. }
33. }
34. ]]>
35. </mx:Script>
36. <mx:Button id="btn" x="10" y="38" label="点击这里" width="100" />
37. <mx:Label id="status" x="10" y="10" text="" width="105" />
38. </mx:Application>