A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [AS3] Detecting stage focus lost

  1. #1
    Senior Member chriserrorplain's Avatar
    Join Date
    Aug 2002
    Location
    london village
    Posts
    623

    [AS3] Detecting stage focus lost

    sorry if I'm being an awful thickie here, but am trying to work out how to detect that a Flash movie no longer has focus (so i can then pause a game and display a 'click here to re-activate game' message), this is do-able in AS3 isn't it?

    Danke,

    ChrisError x

  2. #2
    Professional Air Guitarist Frag's Avatar
    Join Date
    Dec 2002
    Location
    Brain, Body, Clothes, Computer Chair, Room, House, Neighborhood, City, State, Country, Continent, World, Galaxy, Universe, and on?
    Posts
    811
    stage.addEventListener(Event.DEACTIVATE, deactivateListener);

    There's a weird bug in Safari though. If you're holding down a key and you click on another Safari window the event doesn't trigger, but if you click outside the flash movie in the same window or on the desktop it works fine. Works fine in Firefox when I tried the same thing. Weird.

  3. #3
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    I have it done here without mouse click and works as well, just mouse hovering:
    http://www.renderhjs.net/bbs/flashki...une/demo_r112/
    using
    PHP Code:
    stage.addEventListener(Event.MOUSE_LEAVE leaveFunction);
    //and
    stage.addEventListener(MouseEvent.MOUSE_MOVE,returnBackCheckFunction); 
    I just switched a boolean variable between the 2 so I know when the focus is off and when to check for when to switch on back again.

  4. #4
    Senior Member chriserrorplain's Avatar
    Join Date
    Aug 2002
    Location
    london village
    Posts
    623
    yeah thanks guys, have got it working now (athough due to some corner cutting early in my engine, the pause function in my game needs some work)..

    thanks for the help, and hopefully will actually be able to show you all my game soon,


    x

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center