Copy link to clipboard
Copied
Hi, i am student and developing a project for my acadamic and i need to get the messages like wow, good, superb etc... when my score is 100, 200, 300 and so on... somebody help me out to over come this...
Copy link to clipboard
Copied
What code do you have so far for processing the scores? Wherever you change the score value you should be checking the value to see if it requires generating one of the messages.
Copy link to clipboard
Copied
hi ned,
check my code and revert me back with solution. thanks a lot for ur replay.
code:
var myHighScore:int;// high score variable
var soScores:SharedObject = SharedObject.getLocal("mycookie");
var score = 0;
if (soScores.data.myHighScore != null)
{
myHighScore = soScores.data.myHighScore;
}
var ttlScore:int = 0; // total score variable.
zCubeScore.text = "Score: " + local_cube;
zMemLaneScore.text = "Score: " + local_match2;
zMemMathScore.text = "Score: " + local_math2;
zPPatchScore.text = "Score: " + local_ppatch;
zPicSeqScore.text = "Score: " + local_picSequence;
zTotalScore.text = "Score: "+(local_cube+
local_match2+
local_math2+
local_ppatch+
local_picSequence
);
ttlScore = local_cube + local_match2 + local_math2 + local_ppatch + local_picSequence;
if (soScores.data.myHighScore != null)
{
myHighScore = soScores.data.myHighScore;
}
if (myHighScore == ttlScore == 0)
{
myHighScore = 0;
}// the highscore that is saved on the computer.
if (ttlScore > myHighScore)
{
myHighScore = ttlScore;
soScores.data.myHighScore = ttlScore;
soScores.flush();
}
Copy link to clipboard
Copied
"check my code and revert me back with solution"
Are you asking me or telling me?... in either case, I will not be solving your school work for you, but I will try to help you find the solution. You will have to start by indicating where the score value is in your code that you want to base the messages on, and also show where the value changes... that is where you need to check if it equals 100, 200, etc....
Copy link to clipboard
Copied
Use mod. if(score % 100 == 0) then show your wow text, etc.
Copy link to clipboard
Copied
The snippet below show one of the ways how you can match score with a feedback word:
// array containig feedback strings
var feedbacks:Array = ["lame", "good", "wow", "sipurb", "unbelievable"];
// example of score value
var score:int = 1000;
/**
* value that will be used to retrieve feedback string
* note - resutling index value will not exceed the index of the last element of
* feedback array
*/
var index:int = Math.min(score / 100, feedbacks.length - 1);
trace(feedbacks[index]);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now