Copy link to clipboard
Copied
Hi there,
have a very common function i use in educational quizes that self rate the user depending on their score (resulting from answering multiple choice questions). So I have set up a variable called score no trouble...but when i implement my trust "if else" heuristic from AS2...i get all these errors and my flash file does not work.
Is there a better way to code this that I am not aware of ???
stop();
if (score <= 5){
endMsg.gotoAndStop("score1");
} else if (score > 6 and score <= 11){
endMsg.gotoAndStop("score2");
} else {
endMsg.gotoAndStop("score3");
}
feedback movie clip called "endMsg" - depending on function, navigates user to label that provides feedback.
Any help would be awesome...coz this function used to work!!!!! It doesn't even work in Flash CS4 when i retrograde the actionScript panel to version 2 for testing!!!
I missed it... try using
} else if (score >= 6 && score <= 11){
I know they used to support using words for and/or, but never made a practice of it, so I can't say if they don't support it in AS3. Also, as long as there won't be a score of 5.5 you should be okay.
Copy link to clipboard
Copied
As is, there is nothing determinably wrong with that code, except that as written, a score of >5 and <=6 will bring you to the score3 frame. If you show details of the errors you say you are getting it will be easier to determine what might be wrong.
Copy link to clipboard
Copied
Thanks Ned,
I see your point about the code - t'was an oversight. Here it is revised:
if (score <= 5){
endMsg.gotoAndStop("score1");
} else if (score >= 6 and score <= 11){
endMsg.gotoAndStop("score2");
} else {
endMsg.gotoAndStop("score3");
}
And this is the error message I get (Have noticed that debugging/testing is a lot more strict with flash these days...a non fatal error will make the entire swf collapse!)

I hope this image is visible......If not...here it is attached
Copy link to clipboard
Copied
I missed it... try using
} else if (score >= 6 && score <= 11){
I know they used to support using words for and/or, but never made a practice of it, so I can't say if they don't support it in AS3. Also, as long as there won't be a score of 5.5 you should be okay.
Copy link to clipboard
Copied
Thanks again.
I feel quite dim. I have encountered this problem before and solved it doing the same thing.
Amazing how much you can forget!
Copy link to clipboard
Copied
You're welcome.
Copy link to clipboard
Copied
and as Ned said, I still think you should double check your "numbers". Maybe it's better to use something like this:
if (score <= 5)...
else if (score > 5 and score <= 11)...
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more