Skip to main content
Participating Frequently
April 17, 2016
Answered

Flash CS6 AIR device emulator throws deactivate events when sensors change

  • April 17, 2016
  • 1 reply
  • 513 views

I am developing an app in Flash CS6 targeting AIR 21.0.0.176 for Android.  I have set up listeners for NativeApplication.nativeApplication Event.ACTIVATE and Event.DEACTIVATE.  These work as expected when the Android device is running standalone or if I am debugging via the USB interface to CS6. However if I deploy to the local simulator, then whenever I use the simulator interface to generate a change in accelerometer or geolocation, the app receives a DEACTIVATE event.

This makes troubleshooting difficult because on my DEACTIVATE event handler I by stop all interactive functions in the app.

Any ideas please?

This topic has been closed for replies.
Correct answer Colin Holgate

I guess both ways work with the listener setup. It's not a bug though, the Simulator window is a different application, when you select it you have deactivated your app, it's doing the right thing. But in this case you don't want it to do the right thing, so use the work around.

1 reply

Colin Holgate
Inspiring
April 17, 2016

There are various ways to tell if you're running on desktop or not, you can use that to know not to set the activation listeners. I do things like this:

if (Capabilities.version.indexOf('MAC') < 0) {

  stage.addEventListener(Event.ACTIVATE, fl_Activate);

  stage.addEventListener(Event.DEACTIVATE, fl_Deactivate);

}

You could also leave the listeners in and ignore them if you're testing on desktop.

Participating Frequently
April 17, 2016

Thanks Colin.  Is this a known bug in CS6?

Or maybe I am not setting up the listeners the best way?  I am doing this:

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);

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

Colin Holgate
Colin HolgateCorrect answer
Inspiring
April 17, 2016

I guess both ways work with the listener setup. It's not a bug though, the Simulator window is a different application, when you select it you have deactivated your app, it's doing the right thing. But in this case you don't want it to do the right thing, so use the work around.