# Keeping a score in AS 2.0

**URL:** <https://forum.kirupa.com/t/keeping-a-score-in-as-2-0/319945>\
**Category:** flash\
**Created:** [March 9, 2011, 3:57pm UTC](https://forum.kirupa.com/t/keeping-a-score-in-as-2-0/319945 "2011-03-09T15:57:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bicMedium](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@bicMedium](https://forum.kirupa.com/u/bicMedium)\
**Post date:** [March 9, 2011, 3:57pm UTC](https://forum.kirupa.com/t/keeping-a-score-in-as-2-0/319945/1 "2011-03-09T15:57:11Z")

</div>

Hi all - help needed if possible in Flash CS4.

I’ve recently returned to Flash after a few years hiatus, and so am more than a little rusty.

I’m currently developing a simple quiz. Each question has a right and wrong answer, and I want a text box to display the ongoing score.

At present, I have the following code for the first question (which is on frame 3):

[COLOR=Blue]stop();

var score:Number = 0;  
var score = scoreBox.text;

function addScore() {  
if (answer==‘true’){  
score++;  
}  
}

smith01.onPress = function() {  
(addScore==‘true’);  
gotoAndPlay(4);  
}

young01.onPress = function() {  
gotoAndPlay(5);  
}[/COLOR]

[COLOR=Black]The variable [/COLOR][COLOR=Blue]score[/COLOR][COLOR=Black] is, funnily enough, the score. The dynamic text box [/COLOR][COLOR=Blue]scoreBox.text [/COLOR]is where I want the score to be displayed.

[COLOR=Black][COLOR=Blue]smith01[/COLOR] is the button to be clicked for the right answer (which scores 1 point and progresses the user to the next frame), [COLOR=Blue]young01[/COLOR] the button for the wrong answer (which scores no pints and progresses the user to 2 frames on). [/COLOR]

I fully realise that I’m doing something blatantly wrong here - I would appreciate any help anyone could give, and am also quite happy to be ridiculed for my lack of knowledge!

Thanks in advance

Dave
