
Код AS3:
private function initAppHandlers():void {
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, nativeKeyboard_keyDownHandler);
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deactivateHandler)
}
private function nativeKeyboard_keyDownHandler(event:KeyboardEvent):void {
switch (event.keyCode) {
case Keyboard.BACK:
event.preventDefault();
NativeApplication.nativeApplication.exit();
break;
case Keyboard.MENU:
trace("Menu key is pressed.");
break;
case Keyboard.SEARCH:
trace("Search key is pressed.");
break;
}
}
private function deactivateHandler(event:Event):void {
// закрываем в андроиде, а не в эмуляторе
if (Capabilities.playerType.search("Linux") != -1)
NativeApplication.nativeApplication.exit();
}