WHEN: You become so frustrated by an array.push, which inexplicably overwrites every value in the array with the last pushed data, that you create a dummy version of your code to pass around; thinking - in lunatic fashion - that perhaps you've stumbled upon a bug in the compiler.
function testRender(){
var tmpVar:Array = new Array(4);
var dataVar:Array = new Array([0,1,2,3],[4,5,6,7],[8,9,10,11]);
var outVar:Array = new Array();
for(var i:int=0; i<dataVar.length; i++){
for (var j:int=0; j<4; j++){
tmpVar[j] = dataVar[i][j]+10;
}
trace("On iteration " + i + " tmpVar(" + tmpVar + ") is pushed to outVar.");
outVar.push(tmpVar);
}
trace("At end, outVar is: " + outVar);
}
testRender();
...only to realize - before posting it, thank God - that the value you're pushing is not data, (at least as far as the compiler is concerned) but a reference; and therefore all index values of the array end up pointing to the same location in memory. (Solve with .slice() )
Derailed by array fundamentals - Ouch.