I would mark each object (by actually assigning the cloned object as a
property of the original) as I go through each individual clone
operation, and keep a running array of what is being marked. If I hit
something that is already marked, I will use the clone instead of
copying the same object again (because it's hanging off the original).
When I'm finished, I'd remove all the temporary properties from the
originals.

This requires two method instead of one, and is a bit more CPU
intensive, but it won't break.

I'd also be sure to special case the handling of date objects.

The alternative is to shallow clone, which does not recursively copy
object properties, and instead assigns the reference held by the
original to the clone.

Scott

On 24/08/06, Steven Sacks | BLITZ <[EMAIL PROTECTED]> wrote:
> Careful with circular references. Pretty easy to get that one in to
> exceed the 256 recursion limit.

Feel free to post an alternative.  :)

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to