【AS3代码】Timer计时器用法


package
{
     import flash.display.Sprite;
     import flash.events.TimerEvent;
     import flash.utils.Timer;
     public  class Main  extends Sprite
    {    
         private  var a:Timer = new Timer(1000);
         public  function Main():void
        {
            a.delay = 500;          // 时间延迟半秒
            a.repeatCount = 10;         // 一共运行10次
            a.addEventListener(TimerEvent.TIMER, yunxing);     // 运行时调用
            a.addEventListener(TimerEvent.TIMER_COMPLETE, jieshu);     // 运行结束时调用
            a.start();     // 启动计时器
        }        
         // 运行时
         private  function yunxing(evt:TimerEvent):void
        {
            trace("当前已触发次数:" + a.currentCount);
        }
         // 运行结束后
         private  function jieshu(evt:TimerEvent):void
        {
            trace("记时结束!");
        }
        
    }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM