Window focus

  • zoic
  • Beginner
  • Beginner
  • User avatar
  • Posts: 58

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • djones
  • Novice
  • Novice
  • djones
  • Posts: 17
  • Loc: Winston-Salem, NC

Post 3+ Months Ago

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
  • [SteF]
  • Posts: 58
  • Loc: Belgium

Post 3+ Months Ago

_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
  • [SteF]
  • Posts: 58
  • Loc: Belgium

Post 3+ Months Ago

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

Post 3+ Months Ago

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 10 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
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.