actionscript 3 how to keep track of time elapsed?

前端 未结 3 951
无人共我
无人共我 2021-01-05 13:36

im new to actionscript3 flash. I have a int variable and i would like to add +2 every second since game started. How can i do this ? how do i know how much time has elapsed?

3条回答
  •  醉梦人生
    2021-01-05 14:19

    var a:int = 0;
    
    var onTimer:Function = function (e:TimerEvent):void {
        a += 2;
    }
    
    var timer:Timer = new Timer(1000);
    timer.addEventListener(TimerEvent.TIMER, onTimer);
    timer.start();
    

提交回复
热议问题