// DoubleYou
// [flashAPI].mx timer
//
// it's part of [flashAPI] project
//
www.doubleyou.com/flashAPI//
// [02.03.08] nacho@doubleyou.com
/*
constructor :
theTimer = new Timer(miliseconds);
-> miliseconds : miliseconds to launch onTimer event
methods :
start()
-> start the timer
stop()
-> stop the timer
reset()
-> reset the timer to 0
properties :
interval
-> miliseconds to launch onTimer event
events :
onTimer()
-> events launch in each interval
onStart()
-> events lauch at start time
onStop()
-> events launch at stop time
example :
var theTimer = new Timer(1000);
theTimer.onTimer = function()
{
trace("another second left of your life...");
}
theTimer.start();
*/
Timer = function(miliseconds)
{
// length of this timer
this.interval = miliseconds;
}
Timer.prototype.start = function()
{
// reset the timer
this.reset();
}
Timer.prototype.reset = function()
{
// reset the time from which this counts
if (this.ID) clearInterval(this.ID);
this.ID = setInterval(this,"onTimer",this.interval);
}
Timer.prototype.stop = function()
{
clearInterval(this.ID);
this.onStop();
}
=======
下面的1000代表每1000毫秒就执行一次,也就是说你可以调节速度
很方便
var theTimer = new Timer(1000);
theTimer.onTimer = function(){
path.mc.nextframe();
}
theTimer.start();