石头剪刀布
var isReturnPanel:Boolean = false; // 返回面板是否显示,true显示,false没有显示 var rp:ReturnPanel = new ReturnPanel(); // 返回面板 rp.x = 50; rp.y = 300; /// 侦听返回按键,然后取消返回按钮的事件(程序后台运行事件) stage.addEventListener(KeyboardEvent.KEY_DOWN, stageKeyboard); function stageKeyboard(eve:Event):void { eve.preventDefault(); // 取消事件的默认行为,即阻止程序通过返回按键切换到后台 if (!isReturnPanel) { isReturnPanel = true; rp.no.addEventListener(MouseEvent.CLICK, noApp); rp.yes.addEventListener(MouseEvent.CLICK, yesApp); addChild(rp); } } function noApp(eve:Event):void { isReturnPanel = false; rp.no.removeEventListener(MouseEvent.CLICK, noApp); rp.yes.removeEventListener(MouseEvent.CLICK, yesApp); removeChild(rp); mmm.play(); } function yesApp(eve:Event):void { NativeApplication.nativeApplication.exit(); mmm.stop(); } // 当应用程序焦点发生变化时(程序切换到后台),触发该事件 NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, nativeApp); function nativeApp(eve:Event):void { mmm.stop(); } isReturnPanel = false; rp.no.removeEventListener(MouseEvent.CLICK, noApp); rp.yes.removeEventListener(MouseEvent.CLICK, yesApp); removeChild(rp); mmm.play(); } function yesApp(eve:Event):void { NativeApplication.nativeApplication.exit(); mmm.stop(); } // 当应用程序焦点发生变化时(程序切换到后台),触发该事件 NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, nativeApp); function nativeApp(eve:Event):void { mmm.stop(); }
下载地址
用户评论
缺少了点东西