你立即命令你的骰子停在计时器的正下方。删除这些语句并将其重新定位到
throwDiceStop()
作用此外,如果你使用它会更好
flash.utils.setTimeout()
设置一次性计时器,因为在另一种情况下,你可能会错误地创建计时器或无法正确处理其停用(我认为你做得不好,BTW)。
function rollBtnClicked(evt:MouseEvent):void {
throwDice();
setTimeout(throwDiceStop,2000);
}
function throwDice():void {
DiceOne.play(); // don't get started with 0, as it'll end you up
// with consistent animation through different throws
DiceTwo.play();
}
function throwDiceStop():void {
rollNum1 = rollDice();
rollNum2 = rollDice();
DiceOne.gotoAndStop(rollNum1); // and only here select proper values for dice
DiceTwo.gotoAndStop(rollNum2);
// inform the game about the dice finally settling, TODO
}