We need to create 2 listeners - one for focusing in, and one for focusing out. These events are called Event.ACTIVATE and Event.DEACTIVATE.
stage.addEventListener(Event.ACTIVATE, inFocus);
stage.addEventListener(Event.DEACTIVATE, outFocus);
Now we need to show the user that he is focused out or in. Usually, this toggles the pause menu in Flash game, so that if a person focuses on something else, he will see that the game is paused and then proceed to click it to focus on it.
here is the example code:
function inFocus(event:Event){
ball_mc.play()
}
function outFocus(event:Event){
ball_mc.stop();
}
Preview
Download .zip
No comments:
Post a Comment