'FLEX'에 해당되는 글 32건
- 2008.10.23 [FLEX] ArrayCollection Copy 1
The following code will not create a copy but instead will create a reference to the same ArrayCollection.
var a1:ArrayCollection = new ArrayCollection();
a1.addItem(new Object());
a1.addItem(new Object());
var a2:ArrayCollection = new ArrayCollection();
a2 = a1; // a2 and a1 will refer to the same ArrayCollection object
ArrayCollection does not have a copy, concat, join or splice methods which return a new array so we need to do the copy manually.
var a1:ArrayCollection = new ArrayCollection();
a1.addItem(new Object());
a1.addItem(new Object());
var a2:ArrayCollection = new ArrayCollection();
for (var i:uint = 0; i < a1.length; i++) {
a2.addItem(a1.getItemAt(i));
}