O'Reilly logo

Flex 4 Cookbook by Garth Braithwaite, Joshua Noble, Todd Anderson, Marco Casario, Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required