1 Reply Latest reply on Aug 16, 2012 1:21 PM by Flex harUI

    Add an event listener to current window


      I want to add an event to the current window in a browser based program.


      I want to find out when the window is no longer selected. I believe I would want to listen for Event.deactivate, correct?


      Problem though, I don't know how to get an instance to that current window.


      I've tried:


      -Can't add an event listener to that, and I don't even know if that's the window.


      I've also tried:

      var window = this.stage.nativeWindow;

      -When I build I get this error though: Access of possibly undefined property nativeWindow through a reference with static type flash.display:Stage.


      So what do I need to do to get this window? Then, what's the correct event I want to listen for?



        • 1. Re: Add an event listener to current window
          Flex harUI Adobe Employee

          Depends on what you mean by “window”.  A browser-based Flash app defaults to a single browser window with a single FlashPlayer instance whose drawable area is the “stage”.  Clicking outside that area, even on the address bar of the browser window results in an Event.DEACTIVATE.


          If you are using Flex TitleWindows or Panels to create the look of a multi-window app within this stage, there should be WINDOW_DEACTIVATE events and the ActiveWindowManager is keeping track, but you might want to manage the windows on your own anyway.