interesting you should say its the same in as3 jese. i take it you are aware
of peter halls post on this
http://www.peterjoel.com/blog/index.php?archive=2006_02_01_archive.xml#114064012876401732

however that does not work ala as2, since all private members are ignored.
(which leaves me to suspect that value objects is the only way to get
someting like openAMF to work properly using amf1 and as3)
but this is besides the point. in as2 the for each loop is your friend for
cloning objects, but then you also have to consider that some complex
members will not be cloned, but rather a reference to an exisitng object
will just be copied, thus its tricky.

so for true cloning you need to check if somthing is a complex type if it
is, you have to clone that as well, and thus can get messy recursively.



On 3/15/06, JesterXL <[EMAIL PROTECTED]> wrote:
>
> To make a true clone, it's about the same in AS2 & AS3:
>
> class YourModel
> {
>     public var prop:String;
>     public var data_array:Array;
>
>     function YourModel ( p_prop:String )
>     {
>         prop = p_prop;
>         data_array = [1, 2, 3, 4];
>     }
>
>     public function clone():YourModel
>     {
>         var ym:YourModel = new YourModel();
>         ym.prop = prop;
>         ym.data_array = [];
>         var i:Number = data_array.length;
>         while(i--)
>         {
>             ym.data_array[i] = data_array[i];
>         }
>         return ym;
>     }
> }
>
> var a:YourModel = new YourModel("something");
> var b:YourModel = a.clone();
>
> ----- Original Message -----
> From: "Manuel Saint-Victor" <[EMAIL PROTECTED]>
> To: "Flashcoders mailing list" <[email protected]>
> Sent: Wednesday, March 15, 2006 10:21 AM
> Subject: [Flashcoders] Advice on how to make a copy of an object
>
>
> I need to make a local copy of an object- basically I have a model with
> some
> default values and would like each view to create a local model with
> customizations to some parameters.  I've seen some ActionScript 3 ways to
> do
> this but am looking for the way it was done in AS2.
>
> Thanks,
> Mani
> _______________________________________________
> [email protected]
> 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
>
> _______________________________________________
> [email protected]
> 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
>



--
j:pn
http://www.lennel.org
_______________________________________________
[email protected]
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