1 Reply Latest reply on Sep 9, 2009 4:47 AM by Ned Murphy

    Add 10 with every click??

    Ron Colmen Level 2

      Each time I click the "fold_btn" I need to be able to add 10 points and display/update the total in a text box (rot1_txt) . (E.g. 10 clicks will display 100)

       

      on (press) {
      _root.rot1_txt = 0;
      _root.rot1_txt = _root.rot1_txt + 10;
      }

       

       

      Not working!!

        • 1. Re: Add 10 with every click??
          Ned Murphy Adobe Community Professional & MVP

          For the button code you only want to have the adding 10 part.  You will have to assign the zero outside on the timeline in the first frame where the textfield appears.  Also, you will do best to not use the variable property of the textfield and just give the textfield an instance name and assign the value to it via its text propertyuse a variable for the value and capture the value instead.

           

          // on the timeline

          var rot1_txt = 0;

           

          // on the button

          on (press) {
          _root.rot1_txt += 10;
          }

           

          Also, I am assuming you are using the "var" designation of the textfield.  The is not a reliable way to manage the content of a textfield.  You are better off giving the textfield an instance name and assigning content to it via its text property, as in this case where I'm assigning the instance name rot1...

           

          // on the timeline

          var rot1_txt = 0;

          rot1.text = rot1_txt;

           

          // on the button

          on (press) {
               _root.rot1_txt += 10;

               rot1.text = rot1_txt;
          }