Hello again,
I’ve been playing about and discovered a neat simple code snippet to detect if the flash file has focus. By focus i mean if the user has clicked on the embedded flash on a web page.
EXAMPLE
if say you had a game, and the user were to click away accidently? you’d want to use that event to pause the game.
I’m not going to bore you with an explanation of the code as we have covered everything previously.
All we’re using here thats different from before are different events.
function main():void
{
stage.addEventListener(Event.DEACTIVATE, windowNotActive);
stage.addEventListener(Event.ACTIVATE, windowActive);
}
main();
function windowNotActive(e:Event):void
{
trace("NOT ACTIVE");
}
function windowActive(e:Event):void
{
trace("ACTIVE");
}
Demonstration




