Skip to main content
Participant
February 1, 2007
Question

Help Needed: Convert string to number not working in .as file

  • February 1, 2007
  • 2 replies
  • 218 views
Hi, Please anyone here to help me out?

I have this code in my loadxml.as file:
==================================================
function readXML(){

var origInvestment:String = "";
var origInvestmentUSD:String = "";

var TempNum:Number= 0;

origInvestment = String(arrCDN[0]);
//origInvestmentUSD = origInvestment;
TempNum = Number(origInvestment);
if (isNaN(TempNum))
{
origInvestmentUSD ="Has to Be a Number";
}else if (TempNum == undefined )
{
origInvestmentUSD ="Not Defined";
}else if (TempNum == 0)
{
origInvestmentUSD = origInvestment;
}
else
{
origInvestmentUSD = String(TempNum*0.86);
}
}
========================================================

After the input entered, say 100000 through the flash, I can get the output for "origInvestment" alright, but not the USD. Instead, I kept getting the NaN .
When I tried to used var TempNum:Number= Number(origInvestment); , I got "Not defined".

What did I do worng?

Your help is greatly appreciated.
This topic has been closed for replies.

2 replies

Participant
February 1, 2007
Thanks a lot man .

it still gave me a "not define" output.
I think I got an idea why, the string contains "," i.g. 1000,000

I'm trying to figure out a way to get rid of it.
Inspiring
February 1, 2007
var TempNum:Number= parseInt(origInvestment);