Chapter 13. 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 any event listeners that the data they contain has been changed, as well as perform custom logic on any 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 DataGrid and List components to sort and filter their contents. Collections are an integral aspect of working with data-driven controls as well as server-side services returned from a database

The two most commonly used types of collections are the ArrayCollection class and the XMLListCollection class. The ArrayCollection wraps an Array element and provides convenience methods for adding and removing items as well as 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 is particularly powerful when dealing with arrays of XML objects and frequently removes the need for parsing XML into arrays of data objects. ...

Get Flex 3 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.