Problem with scoring system

I’ve made a simple application to help teach children how to measure using a centimetre scale. Random sized and random coloured boxes are generated, the child then drags a rule to measure the box and enters the number in a text box. A check button is clicked to check the answer. If correct the score goes up by 1.
My problem is that if a box size is repeated, the score goes up by 2. For example, a box comes up 2cm wide. I enter 2cm and score 1 point. Several boxes later a 2cm box appears. I put 2cm and score 2 points! Next time I score 3 points.
Obviously I should only score 1 point each time.
The relevant code is:

 
//create a box to be measured
btnAnother.addEventListener(MouseEvent.CLICK, anotherBox);
function anotherBox(evt:MouseEvent):void {
 setUpBox();
 inputBox.text = "";
 feedback.text = "";
//display number of questions asked
 total++;
 questionsAsked_mc.scoreDisplay.text = String(total);
//hide button creating the box and reveal the button used to check the answer
 goButton.visible = true;
 btnAnother.visible = false;
//return rule to original position
 rule_mc.x = 130;
 rule_mc.y = 175;
}
//function to create the box - random dimensions and colour
function setUpBox():void {
var r:Number = Math.random();
var myColor:Number = Math.round( Math.random()*0xffffff );
var p:Number = int(Math.ceil(15*r));
graphics.clear();
graphics.beginFill( myColor, 1 );
graphics.drawRect( 200, 50, p*15, 20 + p*5 );
graphics.endFill();
//Checking the answer
goButton.addEventListener(MouseEvent.MOUSE_DOWN, goClicked);
function goClicked (evt:MouseEvent):void {
 checkAnswer();
}
function checkAnswer():void {
 goButton.visible = false;
 btnAnother.visible = true;
 var q:Number = int(inputBox.text);
 if ( p == q) {     
 totalScore++;
 score_mc.scoreDisplay.text = String(totalScore);
 feedback.text = "Correct! the answer is " + p + " centimetres"; 
  }         
 else {
  feedback.text = "No, the answer is " + p + " centimetres";  
  }  
 }
}
setUpBox();

Hope that makes sense to someone - I’d appreciate any help!