0

I'm building an AIR-based iOS app as pure AS3 from FlashBuilder, and I want to detect ACTIVATE and DEACTIVATE events when the app loses focus.

Much of the docs say to register the event listener against NativeApplication.nativeApplication, but I'm just registering it against this, in the context of the application's Main class. And it works.

Is there any risk to doing it that way? What are the reasons for explicitly using the NativeApplication singleton instance to register event listeners?

Tom Auger
  • 19,421
  • 22
  • 81
  • 104
  • I doesn't matter, as long as the object that is to receive the event is alive (in other words, not garbage collected). – jpop Sep 19 '13 at 20:24
  • Cool. I suppose that in the case where it might be another class (a Controller class, for example) that wants to register the event handlers, you have no choice but to use the Singleton to get at the application. In my case it was the application instance class itself, so it came to the same thing. – Tom Auger Sep 20 '13 at 13:46

1 Answers1

0

The main SWF (this) receives the ACTIVATE and DEACTIVATE events through bubbling. If it's easier to just write the event listener against this, then do it that way. So far I haven't seen any downside to it, and it works really well at detecting loss of app focus. At least on iOS.

Tom Auger
  • 19,421
  • 22
  • 81
  • 104