创造一个AS3(适当的)时间计数器创造一个、计数器、适当、时间

由网友(脸丑怪不得镜子)分享简介:如何创建在AS3时间计数器?在谷歌的一些简单的搜索将指向你的AS3类定时器,其实是事件的计数器和不是一个合适的时间计数工具。How do you create a time counter in as3? Some simple search on google will point you to the AS3 c...

如何创建在AS3时间计数器?在谷歌的一些简单的搜索将指向你的AS3类定时器,其实是事件的计数器和不是一个合适的时间计数工具。

How do you create a time counter in as3? Some simple search on google will point you to the AS3 class Timer that actually is a counter of events and not a proper time counting utility.

我已经看到了这http://blogs.adobe.com/pdehaan/2006/07/using_the_timer_class_in_actio.html而我的事实,这是应该的官方文档有点担心。

I have seen this http://blogs.adobe.com/pdehaan/2006/07/using_the_timer_class_in_actio.html and I am a little worried by the fact that it is official documentation that should work.

问:具体在哪里的问题。

答: Timer类在栈事件执行的操作,如果你有一个pretty的沉重的应用程序,我可以打赌,如果你用它来计算秒计时器会扭曲你的时间,毫秒或什么的。

A: The Timer class executes operations in a stack of events and if you have a pretty heavy application I can bet the timer will distort your time if you use it to count seconds, milliseconds or whatever.

推荐答案

如果你正在寻找正确的测量的时间间隔很短,你只需要使用的getTimer()函数( flash.utils.getTimer ),它返回毫秒经过,因为Flash播放器启动的次数。该原型简单的秒表类是:

If you're looking to accurately measure short intervals of time you just use the getTimer() function (flash.utils.getTimer), which returns the number of milliseconds elapsed since Flash player started. The prototypical simple StopWatch class is:

public class StopWatch {
    private var _mark:int;
    private var _started:Boolean = false;

    public function start():void { _
        mark = getTimer(); 
        _started = true;
    }

    public function get elapsed():int { 
        return _started ? getTimer() - _mark : 0; 
    }
}

更多信息:

阅读全文

相关推荐

最新文章