Thanks for that clarification.  I suppose then we would need to test if o1[i] is an object and if so run clone on that object so it is properly copied.
 
//==========================
//Revised clone:
 
function clone(o1:Object)
{
 var o2 :Object = new Object();
 
 for(var i in o1)
 {
  if(typeof(o1[i]) == "object")
  {
   o2[i] = clone(o1[i]);
  }
  else
  {
   o2[i] = o1[i];
  }
 }
 
 return o2;
}
 
//==========================
 
Bill


>>> [EMAIL PROTECTED] 07/20/05 10:05 am >>>
Depends
If o1[i] is a number or string then is a copy
If o1[i] is another object or array then it is a reference

sebastian

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:bounce-fugli-
> [EMAIL PROTECTED] On Behalf Of barry.b
> Sent: Wednesday, 20 July 2005 10:02 AM
> To: Flash Developers List
> Subject: [fugli] Re: clone object
>
> Bill, I'm just a bit of a lurker on fugli and a beginner in
actionscript
> but I gotta ask:
>
>  for(var i in o1)
>  {
>   o2[i] = o1[i];
>  }
>
> is this just assigning references to o2 from o1? or a deep copy?
>
> just curious
>
> thanx
> barry.b
>
> ---
> You are currently subscribed to fugli as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
[EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/

---
You are currently subscribed to fugli as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/
---
You are currently subscribed to fugli as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to