Groups | Blog | Home
all groups > flash actionscript > february 2007 >

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


DeVanloper
2/1/2007 11:05:21 PM
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.
cinemaguy
2/1/2007 11:07:14 PM
DeVanloper
2/1/2007 11:28:16 PM
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

AddThis Social Bookmark Button