2
votes

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 !

2
Also I saw this tutorial: unitedmindset.com/jonbcampos/2010/09/17/… 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

2 Answers

1
votes

//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();
            }
        }
-1
votes

Have you tried overriding onKeyUp method?

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

        if (keyCode == KeyEvent.KEYCODE_BACK) {
            // Do your stuff
        }
        return false;
    }