• Copying an ArrayCollection

    Posted on August 24, 2008 by in ActionScript, ArrayCollection, Flex Note

    There are multiple ways to copy an arraycollection ..

    1. ac1 = ac2;
    2. ac1 = new ArrayCollection (ac2.source);
    3. ac1 = ObjectUtil.copy (ac2) as ArrayCollection;

    Method 1 copy the ac by reference.
    Method 2 will create an new ac instance, but the value (array) inside two ac are still the same.
    Method 3 will create completely two different objects.

6 Responses so far.

  1. Was an interesting article, thank you..

  2. i come form china , nice to meet you

  3. I saw this really great post today….

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>