Question
Help Needed: Convert string to number not working in .as file
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.
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.