sometimes we need clone a object.but if a displayObject has some children and use the function like this:
function clone(source:*):*
{
var b:ByteArray = new ByteArray();
b.writeObject(source);
b.position = 0;
return(b.readObject());
}
but the result has no children.. .. . so what should I do ?
I didn’t have to program a clone-method myself yet, but i found a way that might do the trick. By iterating through all your variables (in an xml-representation), you can copy them in a new instance of your class.
you can find the method i am talking about on this link: http://www.learnosity.com/techblog/index.cfm/2008/2/6/AS3–Looping-over-properties-of-a-class
Let me know if it works, i’m kind of curious myself 🙂