Return to Kroll Web Design home page Return to Flash / ActionScript page
« Return

Action Script 2 code for U.S. Presidents Quiz:

//Frame 1:

stop();

var score:Number = 0;
var question_nbr:Number = 1;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer2_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer2_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 2:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer2_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer2_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 3:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer3_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer3_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 4:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer1_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer1_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 5:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer3_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer3_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 6:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer1_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer1_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 7:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer2_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer2_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 8:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer1_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer1_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 9:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer3_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer3_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 10:

stop();

question_nbr++;

next_btn._visible = false;

submit_btn.onRelease = function() {
	next_btn._visible = true;
	if (answer2_rb.selected) {
		answer_msg_txt.text = "Correct!";
		answer_president_txt.text = " ";
		score++;		
	}
	else {
		answer_msg_txt.text = "The correct answer is";
		answer_president_txt.text = answer2_rb.getLabel();
	}	
}

next_btn.onRelease = function() {
	nextFrame();
}

//Frame 11:

play_again_btn.onRelease = function() {	
	gotoAndPlay(1);
}

if (score == 10){
	score_comment_txt.text = "Perfect Score! Only direction from here is down!"
}
else if (score == 9) {
	score_comment_txt.text = "Amazing! Hard to believe that you did this well!"
}
else if (score == 8) {
	score_comment_txt.text = "Great!  Highlight of your day, I bet!"
}
else if (score == 7) {
	score_comment_txt.text = "Swell!  This is the score that professional guessers get!"
}
else if (score == 6) {
	score_comment_txt.text = "I'm impressed, but I can't speak for others!"
}
else if (score == 5) {
	score_comment_txt.text = "Half right, half wrong -- is the quiz half empty or half full?"
}
else if (score == 4) {
	score_comment_txt.text = "Just slightly better than chance!"
}
else if (score == 3) {
	score_comment_txt.text = "Hopefully this is only your first attempt!"
}
else if (score == 2) {
	score_comment_txt.text = "Eight wrong sounds more impressive than two right!"
}
else if (score == 1) {
	score_comment_txt.text = "Save your money -- don't buy a lottery ticket!"
}
else if (score == 0) {
	score_comment_txt.text = "Don't feel bad.  Maybe you should run for president!"
}



©2009 Kroll Web Design    davidarthurkroll@verizon.net    781.449.2129

Valid XHTML 1.0 Transitional Valid CSS!