MACROMEDIA FLASH MX 2004-USING FLASH Use Manual page 285

Hide thumbs Also See for FLASH MX 2004-USING FLASH:
Table of Contents

Advertisement

//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.
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
"Schema item settings" on page
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 ActionScript, as
recData
in the runtime example. Then, you bind
the Component inspector.
To access data at design time:
Drag a DataSet component onto the Stage. Name it myDataSet.
1.
Select a layer in the Timeline, and press F9 to open the Actions panel. Type the following code:
2.
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}];
myDataSet.items = recData;
With the DataSet component selected, click the Schema tab of the Component inspector, and
3.
click the Add a Component Property (+) button.
Set the value for Field Name to firstName and leave the Data Type as String.
4.
Create three more component properties for the other name/value pairs in the code: field name
5.
= lastName, data type = String; field name = usCitizen, data type = Boolean; and field name =
age, data type = Integer.
Drag a DataGrid component onto the Stage, and name it myGrid.
6.
Creating fields for a DataSet component at design time is another way to
DataGrid.dataProvider
289.
into
Data management (Flash Professional only)
using
myDataSet.items
285

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents