lundi 2 janvier 2017

AS3: Air For Andriod - Using hardware back key to navigate to last used scene

I have been searching around to find a generic way to use the back key on android devices to go back to the previous scene you were on. All I seem to find is how to make it so the button does not close the application.

Here is my current code:

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true)

function onKeyDown(event:KeyboardEvent):void
{
  if( event.keyCode == Keyboard.BACK )
  {
    event.preventDefault();
    event.stopImmediatePropagation();
    //handle the button press here.

  }
}

Aucun commentaire:

Enregistrer un commentaire