Pausing a timeout is not straightforward. But here's a quick solution:

var intervalID:Number;
var startTime:Number;
var timeLapsed:Number;
var func:Function;
var ms:Number;
function startTimer(func:Function, ms:Number):Void {
   this.func = func;
   this.ms = ms;
   startTime = new Date().valueOf();
   intervalID = setInterval(this, "checkTime", 1);
}
function checkTime():Void {
   timeLapsed = new Date().valueOf()-startTime;
   if (timeLapsed>=ms) {
       clearInterval(intervalID);
       func();
   }
}
buttonInstance.onRollOver = function():Void  {
   clearInterval(intervalID);
};
buttonInstance.onRollOut = function():Void  {
   startTimer(func, ms-timeLapsed);
};
//
startTimer(autoPilot, 5000);
function autoPilot():Void {
   trace("autoPilot");
}

Kenneth Kawamoto
http://www.materiaprima.co.uk

<quote>
I have got a setInterval like this:

-------------
var autoID = setInterval(autoPilot,5000);

function autoPilot():Void {
        nextScene();
};
-------------

If a rollover occurs, I'd like to pause the setInterval until the rollout occurs. Is there a way to suspend the setInterval during a rollover and then restart it onRollOut?
</quote>


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to