How to make the counter never go below Zero or how to count negative number
So I have this counter that I made which basically counts points but it also subtract points. sometimes in certain conditions the counter goes below zero and then I get a weird number 4294967266. my goal is to make counter remember negative numbers but if it's too defunct at least to stop at Zero. Any Ideas?
here is my counter:
//Scoreboard starts here:
var score: uint;
score = 100;
scoreBoard.text = "" + score.toString();
button_10.addEventListener(MouseEvent.CLICK, on_press1);
button_11.addEventListener(MouseEvent.CLICK, on_press2);
//Positive button adding points
function on_press1(event: MouseEvent): void {
gotoAndStop(2);
score += 100;
scoreBoard.text = "" + score.toString();
gotoAndPlay(61);
}
//Negative button subtracting points
function on_press2(event: MouseEvent): void {
score += -20;
scoreBoard.text = "" + score.toString();
}
//Scoreboard ends here:
