Skip to main content
March 24, 2014
Question

messages should come when score is 100,200,300 ....

  • March 24, 2014
  • 3 replies
  • 566 views

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...

This topic has been closed for replies.

3 replies

Inspiring
March 25, 2014

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]);

Inspiring
March 24, 2014

Use mod. if(score % 100 == 0) then show your wow text, etc.

Ned Murphy
Legend
March 24, 2014

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.

March 24, 2014

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();

}

Ned Murphy
Legend
March 24, 2014

"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....