Strange error adding arrays...
Code:
var vProtein:Number = 0;
wProtein = new Array();
for(i=0;i<7;i++){
wProtein[i] = new Array();
for(ii=0;ii<12;ii++){
wProtein[i][ii] = 0;
}
}
The code above makes one variable called vProtein and an array called wProtein and fills that with 0's.
Code:
vProtein = addArrays(wProtein, vProtein);
Then what I'm trying to do with the above code is to pass the array and variable to a function which will add up everything in the array and put it into vProtein.
Code:
function addArrays(array, v){
var arr1:Number = array.length;
for(i=0;i<arr1;i++){
var arr2:Number = array[i].length;
for(ii=0;ii<12;ii++){
v = v+parseInt(array[i][ii]);
//trace(v);
}
}
}
That is the function which will add the values in array and put them into v.
For whatever reason, this is just not working!
When I use trace to find out 'v' in the function it works fine - I can add and remove values from the original array wProtein and v will update fine.
However vProtein which is what v is supposed to be isn't getting updated. I think this is something to do with the scope of v but I thought I was passing vProtein correctly?
Any help on this please?