创造一个AS3(适当的)时间计数器 [英] creating a (proper) time counter in AS3

查看:131
本文介绍了创造一个AS3(适当的)时间计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建在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.

我已经看到了这<一href="http://blogs.adobe.com/pdehaan/2006/07/using_the_timer_class_in_actio.html">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()函数(<$ C C> 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; 
    }
}

<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html#getTimer%28%29"相对=nofollow>更多信息:

这篇关于创造一个AS3(适当的)时间计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆