EasyManua.ls Logo

MACROMEDIA FLASH 8-USING FLASH - Page 422

MACROMEDIA FLASH 8-USING FLASH
678 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
422 Data Integration (Flash Professional Only)
For more information on working with data in the DataSet component, see the
following topics:
About loading data into the DataSet component” on page 422
Accessing the data” on page 424
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 398 and Adding a schema field to a schema item
on page 400. 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
Components Language Reference).
An object bound to the DataSet.dataProvider property. This object should implement
the DataProvider interface; see
DataSet.dataProvider property and “DataProvider
API” in Components Language Reference.
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 424.
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};
}
myDataSet.items = recData;
}

Table of Contents

Related product manuals