# Actionscript 2.0 - Making A Scoring System



## KugarWeb (Apr 6, 2007)

Hi there,

I'm currently working on a number adding game within Flash and have come across a problem with making a total score, as I have had very limited experience with Actionscript (I started learning bits of it last weekend!).

The basic setup of my game is the following:

Question 1 >> Question 2 >> Question 3 >> Question 4 >> Question 5 >> Total Score.

For each question I have two answer boxes, both of which have to be answered correctly for the "order" (related to the game) or question to count. Now I don't want both boxes to be counted, only a score of +1 or 0 for a respective right or wrong answer for each question and then a "Total Score" to be displayed on another frame near the end.

Whether it's right or not I don't know but below is my code so far. I know the right or wrong if statement works perfectly but I'm really not sure on the "score" or how to even attach this somehow to the rest of the game. Please bear in mind that I have an animation for each question so there's bound to be a few second in between each of the questions - is that a problem for actionscript? Also, since there are a lot of layers all to do with each question, I have had to put them in their own folders (e.g. question1, question2 etc.) which I'm guessing shouldn't also be a problem? 


```
score = 0;
order1Right._visible = false;
order1Wrong._visible = false;
nextQ2._visible = false;
alphaQuestion1._visible = false;
checkOrder1.onRelease = function() {
	if (input_banana1.text == 3 || input_banana1.text == "three" || input_banana1.text == "Three" || input_banana1.text == "THREE" && input_orange1.text == 2 || input_orange1.text == "two" || input_orange1.text == "Two" || input_orange1.text == "TWO"){
		input_banana1._visible = false;
		input_orange1._visible = false;
		alphaQuestion1._visible = true;
		order1Right._visible = true;
		checkOrder1._visible = false;
		nextQ2._visible = true;
		score = score +1
	} else {
		input_banana1.visible = false;
		input_orange1._visible = false;
		alphaQuestion1._visible = true;
		order1Wrong._visible = true;
		checkOrder1._visible = false;
		nextQ2._visible = true;
	}
};
stop();
```
Any help with this would be much appreciated!


----------



## TheRobatron (Oct 25, 2007)

To be able to access the score from other frames and movieclips you can declare a global variable: _global.score = 0;

Also I think it might help with the validation if you put each side of the if statement in brackets:

```
if ((input_banana1.text == 3 || input_banana1.text == "three" || input_banana1.text == "Three" || input_banana1.text == "THREE") && 
(input_orange1.text == 2 || input_orange1.text == "two" || input_orange1.text == "Two" || input_orange1.text == "TWO"))
```


----------

