Hi,
The problem is probably quicker explained by just looking at the code (fairly simple).
I have one array. I Have two references to it. When I alter it using the two references this changes the array and tracing the two references. When I use a function to alter the array, tracing the two references to the same array now give different results.
var ar1:Array=new Array(1,2,3,4,9);
var ar2:Array = ar1;
trace(ar1);//1,2,3,4,9
trace(ar2);//1,2,3,4,9
// .... everything as expected so far
ar1[0] = 4;
trace(ar1);//4,2,3,4,9
trace(ar2);//4,2,3,4,9
// .... everything as expected so far
ar1 = AA(ar1);
trace(ar1);//4,2,3,4
trace(ar2);//4,2,3,4,9
// ... huh ? why are these now different ?
function AA(a:Array):Array
{
var tempArray:Array=new Array;
for(var i:uint=0;i<a.length;i++)
{
if(a* < 6) tempArray.push(a*);
//if(a*.stage!=null)tempArray.push(a*);//this is what I am actually using this for; to remove objects that are removed from the display list from the array (not just for GC purposes);
}
return tempArray;
}
I am not sure why the last two traces are not the same ??
Thank you for your consideration!
As the sailor with the ships wheel down his pants said “This is driving me nuts!”
S.