[AS]
var salBase = new LoadVars(); //salBase.Sal = new Number(); //this does nothing, since LoadVars //salBase.MA = new Number(); // always imports strings
salBase.onLoad = function(ok) {
trace(salBase.Sal+ +salBase.MA);
if (ok) {
//this is where your Number conversions go (as before)
sal_txt.text = Number(salBase.MA) + Number(salBase.MA)
//or if you want multiple values from a string like salBase.MA
//split the string first with delimiter “
” which is %0A
//then convert each of the resulting strings into a Number
var MA_array = salBase.MA.split("
");
for(index in MA_array)
MA_array[index] = Number(MA_array[index]);
//‘new’ is optional with the Number function
//then to add them all together,
var sum = 0;
for(index in MA_array)
sum += MA_array[index];
//it would better to perform both actions with a single for loop
//like this
for(index in MA_array)
sum += Number(MA_array[index]);
sal_txt.text = sum;
}
};
salBase.load(“TeachSals.txt”);[/AS]
[AS]var salBase = new LoadVars(); //salBase.Sal = new Number(); //this does nothing, since LoadVars //salBase.MA = new Number(); // always imports strings
salBase.onLoad = function(ok) {
// trace(salBase.Sal+ +salBase.MA);
if (ok) {
//this is where your Number conversions go (as before)
//sal_txt.text = Number(salBase.Sal) + Number(salBase.MA)
//or if you want multiple values from a string like salBase.MA
//split the string first with delimiter “
” which is %0A
//then convert each of the resulting strings into a Number
var Sal_array = salBase.Sal.split("###");
for(index in Sal_array)
Sal_array[index] = Number(Sal_array[index]);
//‘new’ is optional with the Number function
//then to add them all together,
var sum = 0;
// for(index in Sal_array)
// sum += Sal_array[index];
//it would better to perform both actions with a single for loop
//like this
for(index in Sal_array)
sum += Number(Sal_array[index]);
sal_txt.text = sum;
trace(salBase.Sal.split("###"));
trace(Number(Sal_array[0]) + Number(salBase.MA));
}
};
salBase.load(“TeachSals.txt”);
[/AS]
However, I don’t want to add all the values of Sal together; instead, I would like to add the 1 value of MA to each Sal value:
Also, what is the best way to format this into currency when I’m done?
I know it would be quicker/easier to just list the already computated values, but I already know how to do that and want to learn more. So thank you for your time and help.