User Guide
334 Components Dictionary
To create an application using the DataSet component:
1. In Flash Professional 8, select File > New. In the Type column, select Flash Document and
click OK.
2. Open the Components panel if it’s not already open.
3. Drag a DataSet component from the Components panel to the Stage. In the Property
inspector, give it the instance name user_ds.
4. Drag a DataGrid component to the Stage and give it the instance name user_dg.
5. Resize the DataGrid component to be approximately 300 pixels wide and 100 pixels tall.
6. Drag a Button component to the Stage and give it the instance name next_button.
7. In the Timeline, select the first frame on Layer 1 and open the Actions panel.
8. Add the following code to the Actions panel:
var recData_array:Array = [{id:0, firstName:"Mick", lastName:"Jones"},
{id:1, firstName:"Joe", lastName:"Strummer"},
{id:2, firstName:"Paul", lastName:"Simonon"}];
user_ds.items = recData_array;
This populates the DataSet object’s items property with an array of objects, each of which
has three properties:
id, firstName, and lastName.
9. Add the three properties and their required data types to the DataSet schema:
a. Select the DataSet component on the Stage, open the Component inspector, and click
the Schema tab.
b. Click Add Component Property, and add three new properties, with field names id,
firstName, and lastName, and data types Number, String, and String, respectively.
Or, if you prefer to add the properties and their required data types in code, you can add
the following line of code to the Actions panel instead of following steps a and b above:
// Add required schema types.
var i:mx.data.types.Str;
var j:mx.data.types.Num;
10.
To bind the contents of the DataSet component to the contents of the DataGrid
component, open the Component inspector and click the Bindings tab.
11. Select the DataGrid component (user_dg) on the Stage, and click the Add Binding (+)
button in the Component inspector.
12. In the Add Binding dialog box, select “dataProvider : Array” and click OK.
13. Double-click the Bound To field in the Component inspector.
14. In the Bound To dialog box that appears, select “DataSet <user_ds>” from the Component
Path column and then select “dataProvider : Array” from the Schema Location column.