Skip to main content
Inspiring
March 20, 2007
Question

My input AS is right but Flash says it's wrong

  • March 20, 2007
  • 6 replies
  • 310 views
I've done a simple check input coding which should check for the inputed number of 0.09952. Problem is Flash says that the correctly inputed number is incorrect. Can anyone help???

Check out my Flash8 file here:

http://home.exetel.com.au/twistedpancreas/images/calculation.fla

Everything seems to be in order. The only thing i have changed is that my correct number used to be 0.09954, but i changed it to 0.09952. Now only the number 0.09954 will work if var KHPanswer:Number = 0.09954;

Any help would be much appreciated.

Thanks in advance.

PB
This topic has been closed for replies.

6 replies

kglad
Community Expert
Community Expert
March 20, 2007
you're welcome.
Inspiring
March 20, 2007
ah ok,

thx kglad,

i'll try to be a bit more careful next time with my coding
kglad
Community Expert
Community Expert
March 20, 2007
the best way to check for equality of numbers, if to check if their diffence is zero (after converting any strings to numbers). you can also compare strings as you've done in your last message.
Inspiring
March 20, 2007
ok so i've changed it to

var KHPanswer = Number("0.09952");

and that seems to work, so does that mean I need to be ultra careful with how I define numbers in text fields? Because that seemed awefully touchy (ie not accepting 0.09952 but accepting 0.09954!!!)
Inspiring
March 20, 2007
thanks kglad,

so do i write that out as

if (Number(KHP) == KHPanswer)

or

if (Number(KHP.text) == KHPanswer)

because both of those still aren't working with 0.09952
kglad
Community Expert
Community Expert
March 20, 2007
the text property of a textfield is always a string. if you want to compare that string to a number, convert it (using the Number() function is usually adequate).