Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I can certainly do the workaround and appreciate the suggestion.
I do understand your point about why the app is getting the deactivate events. In fact the behavior seems to be that whenever you take focus away from the open CS6 player running the app, even to the main CS6 app itself or the sim controller, it throws a deactivate event. But it seems to me CS6 ought to be smart enough to know that if you are developing an app you don't want to deactivate it by clicking on the simulator controls! That's not simulating the device's actual behavior. Meets the definition of a bug, in my opinion - an unexpected behavior that causes incorrect operation.
But again, thanks for explaining what's going on!