Chapter 12. Collections
Collections are powerful extensions to ActionScript’s indexed array
component, the core ActionScript Array.
Collections add functionality for sorting the contents of an array,
maintaining a read position within an array, and creating views that can
show a sorted version of the array. Collections also can notify event
listeners that the data they contain has been changed, as well as performing
custom logic on items added to the source array. It is this capability of
the collection to notify listeners of data changes that allows data binding,
and it is the collection’s capability to sort its content that allows
ListBase-based components to sort and
filter their contents. Collections are an integral part of working with both
data-driven controls and server-side services returned from a
database.
The three most commonly used types of collections are ArrayCollection, ArrayList, and XMLListCollection. ArrayCollection and ArrayList both wrap an Array element and provide convenient methods for
adding and removing items by implementing the IList interface. By extending the ListCollectionView class, which implements the
ICollectionView interface, ArrayCollection also provides the ability to
create a cursor enabling the last read position in the Array to be stored easily. The XMLListCollection wraps an XML object and provides
similar functionality: access to objects via an index, convenience methods
for adding new objects, and cursor functionality. The XMLListCollection ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access