1 Reply Latest reply on Apr 15, 2009 3:16 PM by kglad

    funky numbers

    Dan74 Level 1

      Hi gang, I came across an issue. I'll simplify it here.


      I've got a button on the stage called "btn1" and an input field with the variable "var2" and the following code in the actions frame:

           var1 = 22.113


           btn1.onRelease = function () {


               if (var1 == var2) {
                   trace("woo hoo");




      When I publish, and enter "22.113" in the input field, traces, but I don't get the woo hoo. I've entered it correctly for sure in the text field. I even tried the following to no avail:


               if (Number(var1) == Number(var2)) {


      But if I try


               if (String(var1) == (var2)) {


      Also, it only happens for some numbers and I can't find a pattern. It works fine for 22.213. It's like the if statement's not accurately reading some numbers. Any suggestions? I'm Really confused!


      Thanks in advance,

      Dan P.

        • 1. Re: funky numbers
          kglad Adobe Community Professional & MVP

          1.  use the text property of textfields, not the associated variable.


          2.  it's easier to remember the text property is always a string.


          3.  compare number to numbers or strings to strings.


          4.  make sure your textfield is not html-enabled (or has kerning enabled).