MACROMEDIA FLASH 8-USING FLASH Use Manual page 425

Using flash
Table of Contents

Advertisement

The following code shows an example of accessing data at runtime. It loads an existing
DataSet component instance
customer's name in the trace window. Notice that the data types for the customer
information—the array of objects—are added so the data displays properly:
//Drag DataSet component to Stage and name it myDataSet (easiest way to
create instance and import necessary libraries)
//Creates recData which contains customer information in an array of objects
var recData = [{id:0, firstName:"Frank", lastName:"Jones", age:27,
usCitizen:true},
{id:1, firstName:"Susan", lastName:"Meth", age:55,
usCitizen:true},
{id:2, firstName:"Pablo", lastName:"Picasso", age:108,
usCitizen:false}];
//Assigns recData to the items property of the "myDataSet" DataSet component
instance
myDataSet.items = recData;
//Adds schema types for the expected fields
var i:mx.data.types.Str;
var j:mx.data.types.Num;
//Makes the first item the current item
myDataSet.first();
//Traces through the properties
while ( myDataSet.hasNext() ) {
//access the data through the Dataset properties
trace(myDataSet.firstName + " " + myDataSet.lastName);
myDataSet.next();
}
Design time example
way to expose the properties of a data object. After the fields are defined, you visually bind UI
controls to the data at design time. You can set additional properties (schema item settings) at
design time for a DataSet field to affect the way data is encoded, formatted, and validated at
runtime. For more information, see
To set up binding to this data at design time, you create persistent fields for the DataSet
component that represent the properties of the object. The following procedure shows an
example of how you would access the same customer information data at design time. You
bind the
array of objects to the items property of the DataSet component in
recData
ActionScript, as in the runtime example. Then, you bind
using the Component inspector.
myDataSet.items
with customer information and then displays each
myDataSet
Creating fields for a DataSet component at design time is another
"Schema item settings" on page
431.
DataGrid.dataProvider
Data management (Flash Professional only)
into
425

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-USING FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF