Copying or cloning arrays
By Thomas HObviously, this is something you already know, but if like me, you didn’t know what happens when you copy arrays this might help.
var a:Array = [new Object(), new Object(), new Object()]; var b:Array; //Create a new reference to the array b = a; //Create a new array but have the same reference to its objects ( shallow copy ) b = a.slice(); b = a.concat(); //faster //A way to actually clone an array and get new instance of the array and new instances of its objects function clone(source:Object):* // function for deep copy { var myBA:ByteArray = new ByteArray(); myBA.writeObject(source); myBA.position = 0; return(myBA.readObject()); } b = clone(a);
Don’t know if this is necessary needed for arrays containing numbers or string values, but for arrays with objects it is.

Cloning the values of an array can be very important say if you’re needing to store an original state of an Array or similar, especially when using an Adapter Pattern.
One thing that you might want to check out is http://flashmoments.novelastudios.com/?p=11
I’d actually like to receive feedback on what appears to be a bug when it comes to doing byte copying.
Thanks,
John Bailey