Using Actionscript 3, How does a player move based on dice result?
I’m developing a game that is based on the popular snake and ladder game as my undergraduate project. It has 36 tiles. Thus far, I’m able to roll the dice but needs the player to move with dice result. I appreciate help. Here is code:
package{
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class peaconty extends MovieClip{
//variables
public var rollBtn;
public var dieMov;
public var boardMov;
public var textResult;
public function peaconty() :void{
rollBtn.addEventListener(MouseEvent.CLICK, rollRandomNumber);
dieMov.gotoAndStop(Math.ceil(Math.random() * 6));
boardMov.gotoAndStop(Math.ceil(Math.random() * 6));
}
function rollRandomNumber(Event:MouseEvent) :void{
//trace(randNumb);
var randNumb:uint = Math.ceil(Math.random() * 6);
textResult.text = "You rolled "+randNumb;
dieMov.gotoAndStop(randNumb);
boardMov.gotoAndStop((currentFrame) +(randNumb));
}
}
}
Working files are here: https://drive.google.com/file/d/0B6-sCCgH269LZGFUamVyVllVOWM/view?usp=sharing
Thanks.