Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to Flash problems with "if" statement

Status
Not open for further replies.

robertaidy

Technical User
Feb 23, 2007
14
GB
Hi I am new to the site and Flash 8. I have a problem with some script, using the "if" statement. I am using one of the Quiz templates and have entered a new Dynamic text field onto the results page to show text saying either pass or fail. the pass mark is 70%. My script so far is:


var tally:Number = (QuizTrack.total_correct + QuizTrack.total_wrong);
var score_temp:Number =((QuizTrack.total_correct/tally*100));
var results_txt:String = "";
var score:Boolean = true;

score = (score_temp >=70);


//trace (tally);
//trace (score_temp);
//trace (score);

if (score = true) {
results_txt = "Congratulations you have PASSED, Your Level Password is:- QWERTY1";
} else {
results_txt = "Sorry - You Failed - Please Try Again";
}

Currently the field will only show the true statement irrespective of the pass mark.

Can anybody help me?
 
You need to use strict equality (double equal signs) in if statement.

ie:

if(score == true) {
etc.etc.etc.

Jonathan
 
Thanks Jonathan, I tried for hours and knew it had to be something simple, you have just made my day thanks again,

Robertaidy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top