AS3 - reactivate "back button" override in Air for Android after task-switching

476 Views Asked by At

I couldn't find an answer to this question, maybe someone around here can help me. I'm coding a game for Android with flash/as3, and override the "back" and "menu" buttons. This works fine by adding eventlisteners and preventing default:

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, myaction);

However, when I press "home", the game minimizes (as it should). But when the users returns to the game after that, these listeners won't fire anymore. Creating new event listeners that I call on Event.ACTIVATE (so when the app is re-focused) wont help either. How can I "reactivate" the back button listeners when the user task-switches back???

1

There are 1 best solutions below

0
ANB_Seth On

Okay I found "my" mistake. I had a line of code called when the app is reopened

"stage.displayState = StageDisplayState.FULL_SCREEN;"

....evidently this disabled the keyboard listeners. Not sure why ... but hell, it works now ^^