User Guide

282 Chapter 14: Data Integration (Flash Professional Only)
The DataSet component uses functionality in the DataBinding classes. If you intend to work
with the DataSet component in ActionScript only, without using the Binding and Schema tabs in
the Component inspector to set properties, you must import the DataBinding classes into your
FLA file and set schema properties in your code. For more information, see “Making data binding
classes available at runtime (Flash Professional only)” in Using Components.
The DataSet component works only with Flash Player 7.
For more information on working with data in the DataSet component, see the following topics:
About loading data into the DataSet component” on page 282
Accessing the data” on page 284
About loading data into the DataSet component
To load data into the DataSet component, you edit the schema for the DataSet and create data
bindings that can be done either in ActionScript or on the Bindings tab of the Component
inspector. You need to edit the schema, in most cases, so that data appears correctly in your
application. For information on editing schema, see Adding a component property to a schema
on page 262 and Adding a schema field to a schema item” on page 263. You can create bindings
for the DataSet component in two ways:
An array of objects bound to the DataSet.items property (see DataSet.items in Using
Components).
An object bound to the DataSet.dataProvider property. This object should implement the
DataProvider interface; see
DataSet.dataProvider property and “DataProvider API” in
Using Components.
The objects can be sophisticated client-side objects that mirror their server-side counterparts, or
in their simplest form, a collection of anonymous objects with public properties representing the
fields within a record of data.
The DataSet component uses functionality in the DataBinding classes. If you intend to work
with the DataSet component in ActionScript only, without using the Binding and Schema tabs in
the Component inspector to set properties, you’ll need to import the DataBinding classes into
your FLA file and set schema properties in your code.
The following examples show different ways you can load objects into the DataSet component,
using either ActionScript code or the Component inspector. The examples assume that you have
specified a schema for the DataSet component on the Schema tab first; see the design-time
example in Accessing the data” on page 284.
Anonymous objects The following ActionScript example assigns an array of 100 anonymous
objects to the
items property of the myDataSet instance of the DataSet component. Each object
represents a record of data.
function loadData() {
var recData = new Array();
for( var i:Number=0; i<100; i++ ) {
recData[i]= {id:i, name:String("name"+i), price:i*.5};
}