Search code examples
androidactionscript-3flashairadobe

Adobe Flash AIR override Android back button


In my AIR AS3 app I'm trying to override Back Button like this:

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

private function onKey(e:KeyboardEvent):void 
{
    if (e.keyCode == Keyboard.BACK)
    {
        //stage.addChild(new MainMenuScreen());
        //stage.removeChild(this);
        //removeEventListener(KeyboardEvent.KEY_DOWN, onKey);
    }
}

It seems to me that my code is getting done but the default Android behaviour (App is closed) is executed as well.
Have someone faced this problem?


Solution

  • Thank you all guys for your help! The problem was due to my FlashDevelop IDE. I used PackageApp.bat instead of Run.bat, so wrong versions of my .apk were deployed onto device. Hope this post will help others who may face this problem