function stringToNum(dec_input:String)
{
var sum:Number = 0;
var dec_length:Number = dec_input.length;
var expCnt:Number = dec_length - 1;
for (var i = 0; i <= dec_length-1; i++) {
var dec_value:Number = (dec_input.charCodeAt(i) - 48);
dec_value *= (Math.pow(10, expCnt));
sum += dec_value;
expCnt -= 1;
}
return sum;
}
|
1 comment:
use the Number function:
function stringToNumber(s:String):Number{
return Number(s);
}
so, there's no need for a stringToNumber() function.
just use Number.
Post a Comment