Also, beware of which operations (.source, for each, toArray) are affected by the current filterFunction / sort of the source ArrayCollection. For example, for each and toArray should skip any filtered element, so you actually end up with a different set of items in the copy.
2013/11/4 mark goldin <[email protected]> > By RESET do you mean collectionChange event? > > > On Mon, Nov 4, 2013 at 8:12 AM, Maurice Amsellem < > [email protected]> wrote: > > > Personally, I am using a third variant: > > > > Target.source = newSource.toArray(); > > > > It has the advantage or not breaking any existing collection listeners, > > and will generate only one RESET event. > > > > Maurice > > > > -----Message d'origine----- > > De : mark goldin [mailto:[email protected]] > > Envoyé : lundi 4 novembre 2013 12:46 > > À : users > > Objet : Copying ArrayCollections > > > > Is the following code functionally identical: > > > > target.removeAll(); > > for each (var item:* in source) > > { > > target.addItem(item); > > } > > > > and this: > > target = new ArrayCollection(source.toArray()); > > > > Thanks > > >
