I have two ArrayCollection now (a, b) and a is set bindable. I want to reset a with b.
The old code in our project is like:
a = new ArrayCollection();
for (var i:int = 0; i < b.length; i++) {
a.addItem(b.getItemAt(i));
}
Then, I think it may cause a potential memory leak. So I changed it to:
a.removeAll();
for (var i:int = 0; i < b.length; i++) {
a.addItem(b.getItemAt(i));
}
Then I read a topic: Flex optimization tip: ArrayCollection.removeAll() vs. ArrayCollection.source = new Array(). Is this a bug ? It says removeAll() will cause a performance problem when the data set is large.
So does it means there is a trick off? If the data set is small I should use removeAll, and if the data set is large, I should not use removeAll()?
Another question, I also read a topic about Changing the source of an ArrayCollection. It says if directly use a = b, "it will kill all the databound controls that are listening to events on the ArrayCollection instance". I don't understand this. I tried a = b, and it works ok (the view that use a as dataprovider updates).
What's the difference between using a=b and a.source = b.source?
I'm new to Flex. Thanks in advance.