Created
March 21, 2013 09:30
-
-
Save k0t0vich/5211804 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function initHandlers():void { | |
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, checkKeypress); | |
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deactivateListener) | |
} | |
public function checkKeypress(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; | |
} | |
} | |
protected function deactivateListener(event:Event):void { | |
// закрываем, если андроид, а не эмулятор или делаем что-то ещё, например закрываем все загрузки и уходим в слип | |
if (Capabilities.playerType.search("Linux") != -1) | |
NativeApplication.nativeApplication.exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment