This has various limitations. For example, it won't work on a DisplayObject because they don't serialize everything required to recreate them.

 

- Gordon

 


From: [email protected] [mailto:[email protected]] On Behalf Of Darron J. Schall
Sent: Tuesday, April 04, 2006 3:31 PM
To: [email protected]
Subject: Re: [flexcoders] cloning was: in operator (F2B2)

 

Gordon Smith wrote:

There is no easy way in Flex 2 to clone an arbitrary type of. Can you
explain why you need to?


Peter posted a neat approach here:  http://www.peterjoel.com/blog/index.php?archive=2006_02_01_archive.xml#114064012876401732

  package com.peterjoel.util {

    import flash.util.ByteArray;{

    public function cloneObject(o:Object):Object{
       var bytes:ByteArray = new ByteArray();
       bytes.writeObject(o);
       bytes.position = 0;
       return bytes.readObject();
    }
  }

-d



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to