Window focus

  • zoic
  • Beginner
  • Beginner
  • User avatar
  • Joined: Sep 06, 2004
  • Posts: 58
  • Status: Offline

Post April 1st, 2005, 3:09 pm

I'm wondering what the actionscript is for seeing if a window is focused or not. I know that it's possible because when I play Flash Flash Revolution and I click somewhere else on my screen, for example I go to notepad or whatever, the game pauses.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 1st, 2005, 3:09 pm

  • djones
  • Novice
  • Novice
  • No Avatar
  • Joined: Sep 15, 2004
  • Posts: 17
  • Loc: Winston-Salem, NC
  • Status: Offline

Post April 1st, 2005, 7:29 pm

This may help:

Code: [ Select ]
if (window.focus == true)
{
Play some stuff
)
else if (window.focus == false)
{
Stop playing stuff
}
  1. if (window.focus == true)
  2. {
  3. Play some stuff
  4. )
  5. else if (window.focus == false)
  6. {
  7. Stop playing stuff
  8. }
  • [SteF]
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jan 14, 2005
  • Posts: 58
  • Loc: Belgium
  • Status: Offline

Post May 28th, 2005, 2:39 pm

_root.onEnterFrame = function() {
if (_root.hitTest(_root._xmouse, _root._mouse, true) == false) {
/*
statements that are going to happen if the mousepointer is on a not-empty area of the stage
*/
} else {
/*
that are going to happen if the mousepointer is on an empty area of our stage or outside the stage
*/
}
}

hope this's usefull
  • [SteF]
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jan 14, 2005
  • Posts: 58
  • Loc: Belgium
  • Status: Offline

Post May 28th, 2005, 2:42 pm

sorry djones, hadn't seen your post yet, your solution looks better :D
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Joined: Jun 26, 2003
  • Posts: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Post May 29th, 2005, 9:20 am

Djones' solution is JavaScript so it won't work in Flash.

However, his method is halfway there. In order to do this you DO need to combine JavaScript and ActionScript.

I've never actually worked with JS communication to Flash, so I don't know how much help I would be, but this should help...

http://www.macromedia.com/support/flash ... withflash/

Also, as a point in the right direction, the javascript function that gets called to communicate to flash whent he window loses focus would be the onBlur event.
PHP Code: [ Select ]
<body onBlur='yourFunction()'>

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 44 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.