1

我对 as3 很陌生,所以这对你们中的大多数人来说可能很明显:P 我正在使用 numPressed 函数(它计算鼠标点击次数)并且需要在第 6 次点击后重置鼠标点击......这个是代码的样子:

var numPressed:Number = 0;
any_mc.addEventListener(MouseEvent.CLICK, countUp);
function countUp(evt:MouseEvent):void {
numPressed++;

if (numPressed == 1) {
any_mc.gotoAndPlay(1);
}
else if (numPressed == 2) {
any_mc.gotoAndPlay(2);
}

else if (numPressed == 3) {
any_mc.gotoAndPlay(3);
}

else if (numPressed == 4) {
any_mc.gotoAndPlay(4);
}

else if (numPressed == 5) {
any_mc.gotoAndPlay(5);
}
}

任何帮助将非常感激!

4

1 回答 1

1

正如 Taurayi 所说,但你也可以像这样清理你的功能。

function countUp(evt:MouseEvent):void 
{
    any_mc.gotoAndPlay(numPressed++);

    if(numPressed > 5)
        numPressed = 1;
}
于 2012-11-17T18:39:57.697 回答