Skip to main content
zebedeeomm
Participant
May 23, 2017
Question

controlling Flash/Animate scene from android keypress/return button

  • May 23, 2017
  • 1 reply
  • 243 views

I am trying to return a Flash/Animate animation published as Air for Android App from one scene to another using the Android return button/keypress. Is this possible and is there Action Script to enable this. I would be very grateful for any guidance with this issue. Many thanks

Zeb

This topic has been closed for replies.

1 reply

Colin Holgate
Inspiring
May 23, 2017

The whole handling the back arrow correctly is a requirement of some of the app stores, especially the Samsung store, so it's good that you're trying to do that.

These lines show the general approach:

//trap the system press of any key

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

//check if the key is the back arrow. If the my variable 'atcontents' is true, 'return', which will have the effect of allow Android to exit the app

//if it's not true, do the code to take you to your contents page, and stop the back arrow from reaching Android OS

function fl_OptionsBackHandler(event:KeyboardEvent):void {

  if (event.keyCode == Keyboard.BACK) {

    if (atcontents) {

     return;

    } else {

      goToContents();

      event.preventDefault();

      event.stopImmediatePropagation();

   }

  }

  event.preventDefault();

}