User Guide

317
12
CHAPTER 12
DataProvider API
The DataProvider API is a set of methods and properties that a data source needs so that a list-
based class can communicate with it. Arrays, recordsets, and data sets implement this API.
You can create a DataProvider-compliant class by implementing all the methods and
properties described in this section. A list-based component could then use that class as a
data provider.
DataProvider class
ActionScript Class Name mx.controls.listclasses.DataProvider
The methods of the DataProvider class let you query and modify the data in any component
that displays data (also called a view). The DataProvider API also broadcasts
change events
when the data changes. Multiple views can use the same data provider and receive the
change
events.
A data provider is a linear collection (like an array) of items. Each item is an object composed
of many fields of data. You can access these items by index (as you can with an array), using
DataProvider.getItemAt().
Data providers are most commonly used with arrays. Data-aware components apply all the
methods of the DataProvider API to
Array.prototype when an Array object is in the same
frame or screen as a data-aware component. This lets you use any existing array as the data for
views that have a
dataProvider property.
Because of the DataProvider API, the version 2 Macromedia Component Architecture
components that provide views for data (DataGrid, List, Tree, and so on) can also display
Flash Remoting RecordSet objects and data from the DataSet component. The DataProvider
API is the language with which data-aware components communicate with their data
providers.
In the Macromedia Flash documentation, “DataProvider” is the name of the class,
dataProvider is a property of each component that acts as a view for data, and “data
provider” is the generic term for a data source.