PDA

View Full Version : Testing a Variable (game score for a quiz game)


beelzebubby
06-20-2008, 11:14 AM
I imagine this a reasonably straight forward question but I'm new to action script so here it is.

Its for a quiz game game
I set my variable in my first frame of my movie ( score = 0)
Ive created two buttons which represent the right or wrong answer which when you click on, add or subtract from the score which is displayed in a dynamic text box (var= score).

What I want to know is how I incorporate a button at the end of the quiz which checks the score and if its under 50 points goes to a fail screen/frame or if over 50 points goes to a pass screen/frame.

Also how could that then be adjusted to be score specific...For instance if the score = 100 it goes to a congratulations screen/frame.

thanks

rajesh2676
06-20-2008, 01:59 PM
Since you have put the buttons and codes in different places, you have to use _global variable. So irrespective of where the codes are, it will add the values to that variable.

For example , you can have code like this,

_global.counter=0;

Initialize this in your first frame and increase the value of this variable wherever you want. Finally you can compare your score with if condition like this

if(counter>=10) {
text1_str = "Congrats"