:stare:
I’m working on something terribly simple, but having ridiculous problems… this is my first experience with Flash, though:
I have a simple dice throwing and I’m implementing a score. I set up a dynamic symbol called points and in the var box I typed pts.
In my dice Actionscript (2.0) I’ve wrote this code, but it does not work… it shows up the first value from the first throw and afterwards, it just resets to 0, no matter how many times I throw the dice. I’ve tried different things, but after researching for a whole day, I’m desperately asking for help! LOL
var pts = Number(0);
roll.onPress = function () {
_root.result.text = 1 + Math.floor(Math.random()*6); /*numbers between 1 and 6 */
trace(_root.result.text);
pts = pts + Math.abs(Number(_root.result.text));
_root.points.pts = pts;
trace(pts);
gotoAndStop(1);
gotoAndStop(10);
invisible();
if (_root.result.text == 1) {
_root.dice_1._visible = true;
//_root.points +=1;
//pts +=1;
//_root.points=pts;
//trace(_root.result.text);
//trace(points);
//trace(pts);
//_root.points = Number(pts);
} else if (_root.result.text == 2) {
_root.dice_2._visible = true;
_root.points +=2;
//pts += 2;
//_root.points=pts
//trace(points);
//trace(pts);
//_root.points.text = Number(pts);
} else if (_root.result.text == 3) {
_root.dice_3._visible = true;
//_root.points +=3;
//_pts += 3;
//_root.points=pts
//trace(points);
//trace(pts);
//_root.points.text = Number(pts);
} else if (_root.result.text == 4) {
_root.dice_4._visible = true;
//_root.points +=4;
//pts += 4;
//_root.points=pts
//trace(points);
//trace(pts);
//_root.points.text = Number(pts);
} else if (_root.result.text == 5) {
_root.dice_5._visible = true;
//_root.points +=5;
//pts += 5;
//_root.points=pts
//trace(points);
//trace(pts);
//_root.points.text = Number(pts);
} else if (_root.result.text == 6) {
_root.dice_6._visible = true;
//_root.points +=6;
//pts += 6;
//_root.points=pts
//trace(points);
//trace(pts);
//_root.points.text = Number(pts);
}
}
function invisible () {
_root.dice_1._visible = false
_root.dice_2._visible = false
_root.dice_3._visible = false
_root.dice_4._visible = false
_root.dice_5._visible = false
_root.dice_6._visible = false
}