Flex Data Providers
Several Flex components, including all list-based controls, display data from a data provider, a collection or object that contains the data displayed by the control.
The data provider concept creates a level of abstraction between components and the data used to populate them. You can think of the data provider as the model, and the Flex components as the view of the model. By separating the model from the view, you can change one without changing the other.
Data-driven components enable the ability to:
- Switch data providers for a component at run-time
- Share the same data provider among multiple components
- Modify a data provider so that changes are reflected by all components that use it
Controls that display application data via a dataProvider property are often referred to as data-driven controls.
Common controls that get their information from data providers:
- List and TileList
- DataGrid
- ComboBox
- Menu
- Tree
- ButtonBar and TabBar
- (More)
Objects commonly used as data providers:
- Array - an array is a simple data provider, but with some shortcomings
- Collection - a collection is a more robust data provider with binding capabilities
- XML - XML...
Arrays as Data Providers
An Array can be used a data provider. Arrays are best used for static (non-changing) or inline data providers.
<mx:ComboBox prompt="Is this a ComboBox?"> <mx:dataProvider> <mx:Array> <mx:String>Yes</mx:String> <mx:String>No</mx:String> <mx:String>Maybe</mx:String> </mx:Array> </mx:dataProvider> </mx:ComboBox>
This example shows an array of strings being used as an inline, static data provider.
If you use a raw data object, such as an Array, as a control's data provider, Flex automatically wraps the object in a collection wrapper. However, the control does not automatically detect changes that are made directly to the source object.
Collections as Data Providers
Collections are ideal data providers because when the contents of a collection change, controls using the collection as a data provider are automatically updated.
Learn more about Collections and their use as data providers...
XML as Data Providers
TODO...
Learn more about XML...
Item Renderers
Flex components that use Data Providers often also use Item Renderers for displaying each item.

