2

I'm developing a simple app for Android using ActionScript 3.0 in Flash CS5 and I'd like to know if there's a way to map the physical back button of the Android's phone to tell my animation to go to the first frame.

I've red that post: Disabling the phone's back button (AIR for Android /ActionScript 3)

so maybe it is possible ? If yes HOW.

Thank you !

Community
  • 1
  • 1
user1418141
  • 33
  • 1
  • 4
  • Also I saw this tutorial: http://www.unitedmindset.com/jonbcampos/2010/09/17/air-for-android-home-menu-back-and-search-buttons/ BUT what is the exact script to go to the first frame and where should I put it ? I mean like any other piece of AS - when I'll export to .apk the device back button will be mapped ? As simple as that ? – user1418141 Aug 19 '12 at 06:03

2 Answers2

1

//first register key down listener

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

//then listen to the back key

private function handleKeys(event:KeyboardEvent):void
        {
            if( event.keyCode == Keyboard.BACK ) {
                logDebug("=>handleKeys.");
                NativeApplication.nativeApplication.exit();
            }
        }
Howy
  • 825
  • 2
  • 10
  • 20
-1

Have you tried overriding onKeyUp method?

@Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_BACK) {
            // Do your stuff
        }
        return false;
    }
Amit Jayant
  • 2,501
  • 2
  • 29
  • 38