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");
}