Hi, > > How do you duplicate an object {bool:true, val:5} in another variable > without pointing to the original one, and without having to create a > constructor. In Director, there's a duplicate() method in Lingo. Is > there an equivalent way to do this in Flash? > > Something like this, but which would actually work: > > var h = {a:true}; > var g = h; > trace(h.a); // true > g.a = false; > trace(h.a); // false, but want to be true, so it's separate from g > object. >
I recently released a library which add this functionality of deep copy to all core objects You can download it here http://www.burrrn.com/projects/core2.html your small exemple will turn like that: var h = { a:true }; var g = h.copy(); trace( h.a ); //true g.a = false; trace( h.a ); //true zwetan _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders