PDA

View Full Version : toNumber?



Licked by a Cow
November 2nd, 2001, 12:05 AM
Hi all,

Is there some function that makes a string into a number? I have an animation where I'd like the user to be able to input a number and then I need to do calculations on that number, but it's not letting me at the moment because the Input Text field gives me a String. Does anyone know how to change this into a number? It would be greatly appreciated, thanks in advance! ;)

Steve

upuaut8
November 2nd, 2001, 01:33 AM
I believe that there is a way of doing that... I'll see what I can find.

suprabeener
November 2nd, 2001, 01:54 AM
Number(string);

upuaut8
November 2nd, 2001, 02:36 AM
thank you Supra.. amazing mind as always..

Licked by a Cow
November 2nd, 2001, 05:01 AM
Thanks, that worked and now I can add numbers from input together and display the result, which is what I wanted. But now I'm running into this problem where they won't compare.

Say I have three input fields, var1, var2, and var3. I want to make it so that it checks if the sum of var1 and var2 == var3. But for some reason when I try it, it never says it works.

Does anyone know what's wrong?

Steve

suprabeener
November 2nd, 2001, 05:11 AM
if(var1 + var2 == var3){...

if that's not evaluating as true, chances are that var1 plus var2 doesn't equal var3.

try using trace(var1+" ; "+var2+" ; "+var3); right before your if statement. that way you can be sure that you're getting the right numbers in the right places.