I’m working on a Flash mobile game. If the app loses focus (a call comes in for example) I need the game timer to stop until focus is restored. Here is my current code but I’m getting a “Argument count mismatch error” onDeactivate(). Expected 0, got 1.
Here is the related code, I think:
addEventListener(Event.ACTIVATE, onActivate);
addEventListener(Event.DEACTIVATE,onDeactivate);
public function onActivate():void {
addEventListener(Event.ENTER_FRAME, showTime);
}
public function onDeactivate():void {
removeEventListener(Event.ENTER_FRAME, showTime);
}
I’m getting the error when testing in flash and I close the window. What am I missing? Thanks for any help you can offer.
onActivate and onDeactivate are event listeners. This means they will be called with event argument. Give them one like this:
onDeactivate(event:Event):void.