【发布时间】:2013-10-15 08:13:35
【问题描述】:
我可以在 actionscript 3 中执行此操作吗?调用定时器函数时,计数器只定义一次
function timer(e:TimerEvent):void
{
static var counter=1;
trace("Times: " + counter );
}
【问题讨论】:
标签: actionscript-3 flash
我可以在 actionscript 3 中执行此操作吗?调用定时器函数时,计数器只定义一次
function timer(e:TimerEvent):void
{
static var counter=1;
trace("Times: " + counter );
}
【问题讨论】:
标签: actionscript-3 flash
怎么样:
function timer(e:TimerEvent):void
{
this.counter = this.counter || 0;
this.counter ++;
trace("Times: " + this.counter );
}
【讨论】:
this.counter = this.counter || 0; 检查是否在计时器函数运行的范围内定义了计数器,如果已定义则使用它,如果未定义则创建一个新的。在这之后只是增加它..