O'Reilly logo

Flex 3 Cookbook by Joshua Noble, Todd Anderson

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

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