timer.stop后timer.currentCount没有重置,timer.reset后,currentCount重置了。
package game.mananger{ import flash.events.TimerEvent; import flash.utils.Dictionary; import flash.utils.Timer; /** *提供 一个 1秒间隔不断跑的timer,可以注册几秒钟回调, * 用于提高性能,全局仅有这一个timer * @author Administrator * */ public class GTimerManager extends BaseManager { private var _timer:Timer; private var _funAry:Array; public function GTimerManager() { if(!_timer) { _timer = new Timer(1000); _timer.addEventListener(TimerEvent.TIMER,_interval); _timer.start(); _funAry = []; } } private function _interval(evt:TimerEvent):void { var len:int = _funAry.length; for(var i:int = 0;i
package game.mananger{ public class GFunInfo { /** * * @param fun 回调函数 * @param delay 间隔秒数 * @isReset isReset 重新add后是否继续上次的计数 */ public function GFunInfo(fun:Function,delay:int,isReset:Boolean) { this.fun = fun; this.delay = delay; this.isReset = isReset; } public var fun:Function; public var delay:int; public var isReset:Boolean; public var temp:int; }}
testGtimer(); private function testGtimer():void { var g:GTimerManager = new GTimerManager(); g.add(new GFunInfo(testGfun,5,true)); g.add(new GFunInfo(testGfun2,1,false)); } private function testGfun():void { trace("testGfun"); } private function testGfun2():void { trace("testGfun2"); }