Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Text fields

Explorer ,
Mar 30, 2016 Mar 30, 2016

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:

exemplo.jpg

Grateful!

TOPICS
ActionScript
333
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 30, 2016 Mar 30, 2016
LATEST

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);

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines