inicio():void{
enableKeyListeners();
}
private function enableKeyListeners():void
{
trace("enableKeyListenersInit");
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleHardwareKeysDown);
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_UP, handleHardwareKeysUp);
}
// Remove keyboard event listeners
private function destroyKeyListeners(e:Event):void
{
trace("destroyKeyListenersInit");
NativeApplication.nativeApplication.removeEventListener(KeyboardEvent.KEY_DOWN, handleHardwareKeysDown);
NativeApplication.nativeApplication.removeEventListener(KeyboardEvent.KEY_UP, handleHardwareKeysUp);
}
// Exit app when Back button is pressed
private function handleHardwareKeysDown(e:KeyboardEvent):void
{
trace("handleHardwareKeysDown");
if(e.keyCode == Keyboard.BACK)
{
//NativeApplication.nativeApplication.exit();
currentState = "categorias";
e.preventDefault();
}
}
private function handleHardwareKeysUp(e:KeyboardEvent):void
{
trace("handleHardwareKeysUpInit");
if(e.keyCode == Keyboard.BACK)
{
e.preventDefault();
//NativeApplication.nativeApplication.exit();
currentState = "categorias";
}