3 Replies Latest reply on Sep 25, 2012 9:10 AM by Ned Murphy

    Score variable problem


      Hi ,

      Having a problem with a basic scoring system


      I have the below on the first frame:



      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



      if (score==100) {



      if (score==80) {



      if (score==60) {



      if (score==40) {



      if (score==20) {



      if (score==0) {



        • 1. Re: Score variable problem
          Ned Murphy Legend

          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") {



          • 2. Re: Score variable problem
            Gater Newcomer

            Thanks very much Ned, it was the numbers as frame lables that was the problem. Amended to the below and it now works fine.



            score = score + "%";


            if (_root.score =="100%") {




            else if (_root.score =="80%") {




            else if (_root.score =="60%") {




            else if (_root.score =="40%") {




            else if (_root.score =="20%") {




            else if (_root.score =="0%") {



            • 3. Re: Score variable problem
              Ned Murphy Legend

              You're welcome