我正在寻找一种解决方案,用于在设备处于空闲状态后检测用户何时解锁屏幕以恢复应用。我需要一个as3解决方案,因为我的应用程序正在运行AIR。
答案 0 :(得分:0)
import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;
stage.addEventListener(Event.DEACTIVATE, onLeave);
stage.addEventListener(Event.ACTIVATE, onComeBack);
function onLeave(event:Event):void{
SoundMixer.stopAll();
stop();
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL;
}
function onComeBack(event:Event):void{
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
gotoAndPlay("1","Main");
}