How to pause a game

ok i have a game that runs on a linear timeline in that certain events are triggered by the amount of time passed in the game, for example if clock == 100, the trigger Super Boss etc etc,

lastTime = getTimer();

function mainTime(evt:Event){
  timeDiff = getTimer()-lastTime;
  lastTime+=timeDiff;
  var clockTime:Number = timeDiff/1000;

}

no too bad right, however at a certain point I would like to pause all events to add a special event, then at I would like to re add the eventListener and have “clockTime” resume where it left off, does that make sense,

I am able to effectively remove the EL and add it back, however, the ‘clockTime’ continues to add even when EL is remove, this makes sense of course, since ‘lastTime’ was initialized at the beginning of the game,

my question is how do i halt ‘clockTime’ from ticking when pausing the game?

You could maybe try something like this:

var startTime:int = getTimer();
var clockTime:int;

function mainTime(evt:Event)
{
    clockTime = (getTimer() - startTime)/1000;
}



function specialFunction()
{
    // grab the current time
    var specialFunctionStartedAt:int = getTimer();
    
    // do the special function 
    // ......
    // ......
    
    // when that's all done
    var specialFunctionDuration:int = getTimer() - specialFunctionStartedAt;
    startTime += specialFunctionDuration;
        
}

Thanks, I will give it a try later

Nice dude, that works! thanks