Skip navigation
Currently Being Moderated

Add an event listener to current window

Aug 16, 2012 7:24 AM

Tags: #event #window #event_listener

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:

FlexGlobals.topLevelApplication

-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?

 

Thanks!

 
Replies
  • Currently Being Moderated
    Aug 16, 2012 1:21 PM   in reply to eZACKe

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points