5 Replies Latest reply on Mar 17, 2010 7:08 AM by Ned Murphy

    Adding Numeric Variables

    cre8ive1974 Level 1

      I would like to add several numeric variables together and have the result placed in another variable.  I would also like this to happen automatically as the user inputs numbers into the input fields.

       

      On the stage I placed two input text fields and named them "score1" and "score2".  I also placed a dynamic text field on the stage and named it "total"

       

      the actionscript I am using is

       

      onEnterFrame=function(){
      total = (score1+score2)
      }

       

      If I input in text field score1 "6"  and I input in text field score2 "8"  I get a result in the total text field of 68, when I am expecting 14.

       

      If I use any other operator (subtract, multiply, divide etc.) it calculates correctly, so I'm pretty sure it has to do with somehow declaring that  the variables are to be declared as a number, but I am unsure how to do  that in this example.

       

      Any help would be appreciated.

      Thanks

      D