Skip to main content
plungeint
Participating Frequently
November 24, 2011
Question

Deactivate event not firing? - AIR + Flash + Android

  • November 24, 2011
  • 1 reply
  • 2653 views

Hi,

When I play a flash game in Android (using AIR apk compilation), and then press the device's "HOME", the game keeps running, and I even hear the gameplay sounds!

Then I tried to do this:

NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);

private function quitGamesButtonClicked(mouseEvent:MouseEvent):void {

   Object(parent).gotoTitlePage();

}

But it does not seem to work. That is the code that should prevent the mentioned issue? Should I put that code in some specific place?

Thanks!

-- PS: I get an error when runing the ADT command,: error 307 descriptor must be at least namespace 3.0, but then I change the xml files to 3.0, to be able to generate the apk, maybe this has something to do with it?

This topic has been closed for replies.

1 reply

Colin Holgate
Inspiring
November 24, 2011

You don't show what your deactivateHnadler does.

Do you have code in place to pause and resume the game, including the shutting off of sound? If you do, call that on deactivate, and call the resume function on activate.

At the very least, do a SoundMixer.stopAll() in the deactivate function. That would stop the sound from playing.

plungeint
plungeintAuthor
Participating Frequently
November 24, 2011

Hi Colin,

This is exacly what I do:

NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, function(event:Event) {
    NativeApplication.nativeApplication.exit();
}, false, 0, true);
  
NativeApplication.nativeApplication.addEventListener(Event.EXITING, function(event:Event) {
    NativeApplication.nativeApplication.exit();
}, false, 0, true);