Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 Actionscript计时器不工作';循环次数过多后停止_Actionscript 3_Loops_Timer - Fatal编程技术网

Actionscript 3 Actionscript计时器不工作';循环次数过多后停止

Actionscript 3 Actionscript计时器不工作';循环次数过多后停止,actionscript-3,loops,timer,Actionscript 3,Loops,Timer,请帮忙!我不明白为什么我的计时器在循环数之后没有停止。我在开头声明了一个变量“roundCount”。计时器应该在它的值为零时停止,对吗?但是它不断地递减“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:MouseEven

请帮忙!我不明白为什么我的计时器在循环数之后没有停止。我在开头声明了一个变量“roundCount”。计时器应该在它的值为零时停止,对吗?但是它不断地递减“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);
}

根据这段代码,roundCount是0,所以您可以用repeatCount 0启动计时器,它是mean-repeat forever。 此外,roundCount不会递减。从中减去penaltyTimer.currentCount

要使计时器在您的情况下执行3次,您必须

确保创建计时器时,roundCount为3。创建计时器对象后更改值不会反映到计时器。

AzzyElvul-我的计时器不是从零开始,而是从10开始,因为我更改了conPoint函数中的roundCount变量值。但即使它从10开始,它也不会在零处停止,而是继续下去。不!计时器从0开始。您可以在这里创建它:var penaltyTimer:Timer=new Timer(roundLength,roundCount);此时,roundCount为0。在conPoint中,您将roundCount设置为10;但这并没有反映到penaltyTimer——它已经被创建了。在倒计时中,只需从roundCount-penaltyTimer.currentCount中减去。要查看计时器将重复多少次,请参见.repeatCount属性(penaltyTimer.repeatCount)检查此项:因此,如果要重复10次,请设置var roundCount:uint=10;