|
-
Help with a scoring system.
Last edited by Cralant; 11-22-2009 at 07:44 PM.
-
Try this:
Code:
If (score > 0 && score <= 100) {
txtFinalRank.text = "You're a beguinner. Keep trying.";
} else if (score > 100 && score <= 200) {
txtFinalRank.text = "Not enough. Do your homework.";
/* AND SO ON, YOU CAN ADD AND ADAPT THESE TWO LINES AS FAR AS YOU WISH:
} else if (score > 200 && score <= 300) {
txtFinalRank.text = "Not enough. Do your homework.";
*/
}
Tell me if it works.
One idea. One emotion. One project.

-
still not working
Im not sure where i am ment to put this but i put it on the layer containing the dynamic text box and that does not work it gives me the errors:
Location || Description || Source
Scene=Scene 1, layer=actions, frame=4, Line 11 || Syntax Error || If (score > 0 && score <= 100) {
Scene=Scene 1, layer=actions, frame=4, Line 13 || 'else' encountered without matching 'if'' || } else if (score > 100 && score <= 200) {
The actions on my layer are:
Code:
stop();
_root.onEnterFrame = function(){
if(Key.isDown(32)){
gotoAndPlay(2);
}
}
If (score > 0 && score <= 100) {
txtFinalRank.text = "Dude you suck";
} else if (score > 100 && score <= 200) {
txtFinalRank.text = "Not enough. Do your homework.";
/* AND SO ON, YOU CAN ADD AND ADAPT THESE TWO LINES AS FAR AS YOU WISH:
} else if (score > 200 && score <= 300) {
txtFinalRank.text = "Not enough. Do your homework.";
*/
}
So yeah it does not work i can give you a 'test' flash if you would like one.
-
//create a new layer.
//add a key frame where the score page is.
//place this on the frame
Code:
selectedRank = 0
rank0 = ""
rank1 = "you suck"
rank2 = "realy?"
rank3 = "hmmm try again?"
//ect
if(score < 100){
selectedRank = 1
}
if(score >= 100){
selectedRank = 2
}
if(score >= 150){
selectedRank = 3
}
//ect
txtFinalScore.text = 'Final Distance: '+score +' Meters';
txtFinalRank.text = _root["rank"+selectedRank]
this method lets you easily add and change your rank responses, as they are set to variables.
hope this helps ^^
Freelance: AS2, AS3, PHP, MySQL, JavaScript
Skype: hunty93
-
Im a donut.
Im sorry for wasting your time i just realised that i gave the instance name 'txtFinalank' when it was ment to of been 'txtFinalRank' on the dynamic text box.
Both methods worked perfectly just my foolish mistakes wasted time.
Thank you.
Cralant
-
My mistake:
At the very begining of my code I wrote "If", but it should be "if".
Sorry.
I see hunty93's answer is better than mine because is very clear and is dynamic.
He uses _root["rank"+selectedRank] to make your life easier. When you use this[] or _root[], you're able to transform strings plus variables to pieces of code.
So, in each case, hunty93's code becomes:
txtFinalRank.text = rank0; // ""
txtFinalRank.text = rank0; // "you suck"
txtFinalRank.text = rank0; // "realy?"
txtFinalRank.text = rank0; // "hmmm try again?"
One idea. One emotion. One project.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|