我需要帮助检测和处理运行AIR应用程序的iPhone / iPod Touch上按下的主页按钮。我试过了
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
function handleKeys(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.HOME) {
//do something
}
}
没有运气。有任何想法吗?具体来说,我想在按下主页按钮时阻止应用程序关闭。
答案 0 :(得分:0)
import flash.events.Event;
addEventListener(Event.ACTIVATE, activateListener);
addEventListener(Event.DEACTIVATE, deactivateListener);
private function activateListener(e:Event):void{
//do something when awakened
}
private function deactivateListener(e:Event):void{
//do something when home button is pressed.
}