1 Reply Latest reply on Apr 17, 2006 10:35 AM by NSurveyor

    Math Equation getting info from Input Text field - Flash 8

    NS5
      Hello

      I am trying to do a simple interaction for a training course. The interaction is measuring if someone is X amount of pounds overweight it puts y amount of additonal pressure on the back.

      I want the user to be able to input any number of pounds overwight up to 3 digits and when they click the calculate button the total will fill in the dynamic text box below.

      I have 2 variables set
      overweight is the variable name for the input text box
      pressure is the variable name for the dynamic text box

      On the first frame I am setting these variables
      overweight = "000"
      pressure = "000"

      For the Input text box I have the name overweight in the Var option in properties and for the dynamic text box I have the name pressue in the Var option in properties.

      The math itself is simple. What ever amount of pounds they enter as overweight just needs to be multiplied by 10 and displayed in the dynamic text box.

      This is the code for the calculate button
      calculate.onRelease = function () {
      pressure = int(overweight*"10");
      trace(overweight)
      }

      The problem I think I am running into is that it is not reading what the user puts into the input text box as a number because when I trace it it is giving the the text box attributes not the number the user typed in.

      I really appreciate any help

      --Thanks

        • 1. Re: Math Equation getting info from Input Text field - Flash 8
          NSurveyor Level 2
          First of all, don't use the Var property, give your textfields instance name. For example, give the overweight textfield, the instance name: overweight_txt. And give the other, pressure_txt.

          And also, the contents of textfields are STRINGS, not NUMBERS, and therefore you can't really do the desired calculations. You have to convert the strings into numbers:

          calculate.onRelease = function () {
          pressure_txt.text = parseFloat(overweight_txt.text)*10;
          }