Call e.updateAfterEvent()
after setting stage's frame rate. This forces a single redraw of the stage, after that the stage's framerate set to 0 kicks in, and the stage does not get redrawn anymore until you restore its framerate.
Update: apparently it is a bug in Flash player 11.3 (maybe more of FP11) that wasn't in place with FP10, so the "naked" approach as in the tutorial worked for me when I used a debugger FP10 that comes with FlashDevelop, but didn't work when I have tried it in my FF with FP11.3 installed. So the workaround is as follows: Add a bogus Sprite
object into your code, do not add it anywhere, it will serve as a recipient of a custom MouseEvent
event for the sole purpose of calling updateAfterEvent()
. This worked for me to display a custom DisplayObject that signifies the paused state.
private var pausedRecipient:Sprite=new Sprite();
// do not add child so that its listener won't trigger on user input
pausedRecipient.addEventListener(MouseEvent.CLICK,uae);
private function uae(e:MouseEvent):void {e.updateAfterEvent();}
private function onDeactivate(e:Event):void {
pauseGame=true;
addChild(FocusScreen);
if(musicOn==true){
musicCh.stop();
}
pausedRecipient.dispatchEvent(
new MouseEvent(MouseEvent.CLICK,true, true, -1, -1, stage));
// ^ this does the trick of indirect call of updateAfterEvent()
}