Skip navigation
Gater
Currently Being Moderated

Score variable problem

Sep 25, 2012 5:50 AM

Hi ,

Having a problem with a basic scoring system

 

I have the below on the first frame:

 

stop();

var score:Number = 0;

 

with a dynamic text area with the variable score

 

Then certain frames with:

_root.score += 20;

 

this all works fine

 

The problem is when I want a mc to go to a certain frame depending on the final score, i have the below but not working, any suggestions would be welcomed

 

stop();

if (score==100) {

    options.gotoAndStop("100");

}

if (score==80) {

    options.gotoAndStop("80");

}

if (score==60) {

    options.gotoAndStop("60");

}

if (score==40) {

    options.gotoAndStop("40");

}

if (score==20) {

    options.gotoAndStop("20");

}

if (score==0) {

    options.gotoAndStop("0");

}

 
Replies
  • Currently Being Moderated
    Sep 25, 2012 7:45 AM   in reply to Gater

    First, if those are frame numbers in your goto lines, do not use quotes.  If they are frame labels, do not use numbers for frame labels.

     

    You should avoid using the var property of a textfield and just read the text property of the textfield.  So overall, using a variable, your code would switch the numbers with the strings, as in...

     

    if (score.text == "100") {

        options.gotoAndStop(100);

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2012 9:10 AM   in reply to Gater

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points