Extend the TextInput Class/component to accept a "value" property as a number. I know there is a restrict method, that only allows for specified characters. The problem I am having is using a textinput to take the value in the box and apply it to math equations in a script. Any ideas?
+1
A:
You can restrict the TextInput
to 0-9.
and then use its value in the script by casting it to a Number.
Math.sqrt(Number(textInput.text));
Amarghosh
2009-10-08 04:36:45
A:
In addition to Amarghosh's:
You'll need to restrict something like this: "0-9\-" if you allow negatives. (yes triple-escaped...)
Also, there's the parseInt and parseFloat methods if you need specialized options like parsing from Hex.
Just make sure you check your result for NaN: isNan(result)?
.
Glenn
2009-10-24 12:02:40