Skip to main content
Participant
October 17, 2006
Question

Iam not able to take and display numbers..Plz help

  • October 17, 2006
  • 2 replies
  • 320 views
Guys I am a beginner and have landed into trouble cause of it.. I know the basics but a typical situation has arrived.. I want to take user entered number and display it back!!!! but here I get two types of error 1. NaN i guess which means not a number and the other 2. which Says undefined... The code iam writing is

on(press)
{
var number = txt_box.text; //txt_box is the name I have assigned to the text box cause i read how to do it somewhere!
num_out.text = number; // num_out is another dynamic box name....
}

I have tried using the string instead of text.... Found in another place... Then used a function Number() which as read could change a string to a number and also I used a function called parseInt().. Which also dint help.. But it would be a grrrrrrrrreat help if someone could give me a simple code to this prob and explain what was the actual problem.. Is that I was Dumb or it was my ignorance?
This topic has been closed for replies.

2 replies

Inspiring
October 17, 2006
first of all ..
using number as a variable name is wrong as Number is a valid class in flash.
another
instead of using Number to typecast use parseInt(String) to typecast.
on(press)
{
var num:Number = parseInt(this._parent.txt_box.text); //txt_box is the name I have assigned to the text box cause i read how to do it somewhere!
this._parent.num_out.text = num; // num_out is another dynamic box name....
}
Inspiring
October 17, 2006
I could be wrong but I think that using the word "number" might be part of your problem. Since "Number" is a reserved word, I believe it might be an issue.

Have you given your dynamic text fields a variable name in the properties panel?