加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

actionscript-3 – 在AS3中,当值大于最大int时,getTimer()将返回

发布时间:2020-12-15 07:22:59 所属栏目:百科 来源:网络整理
导读:每 Adobe getTimer()是: Used to compute relative time. For a Flash runtime processing ActionScript 3.0,this method returns the number of milliseconds that have elapsed since the Flash runtime virtual machine for ActionScript 3.0 (AVM2) sta
每 Adobe getTimer()是:

Used to compute relative time. For a Flash runtime processing ActionScript 3.0,this method returns the number of milliseconds that have elapsed since the Flash runtime virtual machine for ActionScript 3.0 (AVM2) started.

因为getTimer返回一个int,其中:

The int class lets you work with the data type representing a 32-bit signed integer. The range of values represented by the int class is -2,147,483,648 (-2^31) to 2,647 (2^31-1)

getTimer()在2,647毫秒后返回什么?我认为这大约是连续运行24.85天.不是通常情况,而是数字标牌和信息亭环境完全可行.

在这些情况下应该避免使用getTimer()吗? Date.UTC()对象是否会更安全,因为它返回一个Number类型?

解决方法

我的猜测是它会循环回来,就像int一样.

var nt:int = int.MAX_VALUE + 10; //outputs -2147483639
var nt2:int = int.MIN_VALUE + 9; //outputs -2147483639

如您所见,MAX 10与MIN 9相同(显然必须考虑最小值本身).因此,当你达到24天的标记时,它可能看起来像-24天并开始重新开始.

函数本身也有可能不会返回实际时间,但这些内容也是如此:

return timer % int.MAX_VALUE;

这将使用简单模数将每次达到MAX_VALUE时的时间重置为0.老实说如果这就是他们所做的事情就不会感到惊讶(因为你不想要负面的运行时,显然)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读