本站原创文章,转载请注明: 转载自zrong's Blog,原文 在关闭AIR程序窗口前显示Alert,欢迎使用文章源码进行转载。
本站转载文章会标明[转],转载请注明原始作者文章地址。
?Download AIRClose.mxml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" showStatusBar="false" closing="closeHandler(event)"> <mx:Script> <![CDATA[ import org.zengrong.utils.Dialog; private function closeHandler(evt:Event):void { trace(evt.toString()); evt.preventDefault(); Dialog.confirm('确定退出?', _close); } private function _close($yes:Boolean):void { if($yes) this.nativeApplication.exit(); } ]]> </mx:Script> </mx:WindowedApplication> |
有关Dialog的用法与最新源码,详见zrong’s Class(下附源码)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | package org.zengrong.utils { import flash.display.Sprite; import mx.controls.Alert; import mx.core.Application; import mx.events.CloseEvent; public class Dialog { public static function alert($info:String, $title:String=''):void { Alert.show($info, $title, 4, Application.application as Sprite); } /** * 弹出confirm确认对话框,根据用户的交互返回是否确认布尔值 * @param $s 要显示的信息 * @param $closeFun 关闭确认对话框时调用的函数 */ public static function confirm($s:String, $closeFun:Function):void { var __fun:Function = function(evt:CloseEvent):void { $closeFun(evt.detail == Alert.YES); } Alert.show($s, '', Alert.YES|Alert.NO, Application.application as Sprite, __fun); } } } |


谢谢