Actionscript Timer在循环次数后不会停止

时间:2013-02-28 15:20:59

标签: actionscript-3 loops timer

请帮忙!我无法弄清楚为什么我的Timer在循环次数后不会停止。我在开始时声明了一个变量“roundCount”。当它的值为零时,Timer应该已经停止了,对吧?但它继续减少“roundCount”3,2,1,0,-1,-2,-3等的值。

var roundLength:uint = 1000;
var roundCount:uint = 0;

con_btn.addEventListener(MouseEvent.CLICK, conPoint);

function conPoint(m:MouseEvent)
{
    if (cB.height == 60)
    {
        conductSigns.conductMasker.y = 27;
        roundCount = 10;
        penaltyTimer.start();
    }
}

var penaltyTimer:Timer = new Timer(roundLength,roundCount);
penaltyTimer.addEventListener(TimerEvent.TIMER, countDown);

function countDown(t:TimerEvent):void
{
    timeOut_txt.text = String(roundCount - penaltyTimer.currentCount);
}

1 个答案:

答案 0 :(得分:0)

从这个代码开始,roundCount为0,所以你用repeatCount 0启动计时器,这意味着 - 永远重复。 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html#Timer() roundCount也不会减少。你从它中减去了penaltyTimer.currentCount

要使计时器在你的情况下执行3次,你必须 确保创建计时器roundCount为3.创建计时器对象后更改值不会反映到计时器。

相关问题