Copy link to clipboard
Copied
I wonder how can I be creating a text field where the user may be clicking in the box and add any number to choose it.
And how can I do to set the variable will only store numeric values using a Number?
Example of text fields which I refer:
Grateful!
Copy link to clipboard
Copied
assign each textfield an instance name (in the properties panel). eg, tf_1 and tf_2.
you can use the restrict property of textfields to restrict user input to numbers. eg,
tf_1.restrict='0-9';
and you can use the addF function to return the sum of the textfields:
function addF(tf1:TextField,tf2:TextField):Number{
if(isNaN(Number(tf1.text)) || isNaN(Number(tf2.text)){
return -1;
} else {
return Number(tf1.text)+Number(tf2.text);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now