2 Replies Latest reply on Apr 21, 2011 7:04 AM by Ned Murphy

    Sum

    sensiblemind

      hi all

      i made 8 input txt  and one Dynamic to collect all the input in it

       

       

      here is the code

      ///////////// Dynamic text

      var GF_w:Number = 0;

      //////////////////////////// input texts

      var w_1:Number = 0;

      var w_2:Number = 0;

      var w_3:Number = 0;

      var w_4:Number = 0;

      var w_5:Number = 0;

      var w_6:Number = 0;

      var w_7:Number = 0;

      var w_8:Number = 0;

      ////////////// BUTTON

       

      collect__mc.onPress = function()

      {

      GF_w = w_2+ w_1+ w_3 + w_4 + w_5 + w_6 + w_7 + w_8;

      };

      BUT it seems like there is something wrong

       

        • 1. Re: Sum
          kglad Adobe Community Professional & MVP

          you should be using the text property of your textfields, not their associated variables.  and, you need to cast those strings as numbers:

           


          ///////////// Dynamic text

          var GF_w:Number = 0;

          //////////////////////////// input texts

           

          var w_1:Number = 0;

          var w_2:Number = 0;

          var w_3:Number = 0;

          var w_4:Number = 0;

          var w_5:Number = 0;

          var w_6:Number = 0;

          var w_7:Number = 0;

          var w_8:Number = 0;

           

          ////////////// BUTTON

           

          collect__mc.onPress = function()

          {

          GF_w = Number(w_2)+ Number(w_1)+Number( w_3) + Number(w_4) + Number(w_5) + Number(w_6) + Number(w_7) + Number(w_8);

          };

           

           

           

          • 2. Re: Sum
            Ned Murphy Adobe Community Professional & MVP

            How can you tell something seems wrong?

             

            You are probably using the variable (var) property of the textfield, which is not a recommended practice (likely why it no longer exists in newer Flash versions).  It is unreliable at best.  You should just assign instance names to the textfields and work with the text property of the textfield, converting to Number values as needed.