This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Flash Site Design > April 2004 > String to Number!!!





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author String to Number!!!
Billy

2004-04-29, 10:33 pm

Can anyone tell me how to convert a string into a number? E.g.

var holder:LoadVars=new LoadVars();
for(var i=1; i<=2;++1){
holder.number1=10;
holder.number2=20;
var contents1:Number = eval("holder.number+i);
var contents2:Number = eval("holder.number2"+i);
}
output_txt.text=contents1+ contents2

I need this to output 30 but it just concatenates the values all the time!
i.e. 1020

Please help


Billy

2004-04-29, 10:33 pm

No problem - I used parseInt and it now works fine!

Hope this helps someone else on here!


James Fee

2004-04-29, 10:33 pm

I have used the following:

var myNum:Number = Number(myStringNumber);

I think that will work for you (haven't actually gotten to the point in my
project where I can test that).

--
Jim Fee
Viking Electronic Services
jfee (at) vikinges (dot) com


"Billy" <info@bem-management.takethisbpartout.com> wrote in message
news:cp7kc.58$cK.48@newsfe3-win.server.ntli.net...
> Can anyone tell me how to convert a string into a number? E.g.
>
> var holder:LoadVars=new LoadVars();
> for(var i=1; i<=2;++1){
> holder.number1=10;
> holder.number2=20;
> var contents1:Number = eval("holder.number+i);
> var contents2:Number = eval("holder.number2"+i);
> }
> output_txt.text=contents1+ contents2
>
> I need this to output 30 but it just concatenates the values all the time!
> i.e. 1020
>
> Please help
>
>



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews