User Guide
DataSet class (Flash Professional only) 335
15. To bind the selected index of the DataSet component to the selected index of the DataGrid
component, select the DataGrid component on the Stage and click the Add Binding (+)
button again in the Component inspector.
16. In the dialog box that appears, select “selectedIndex : Number”. Click OK.
17. Double-click the Bound To field in the Component inspector to open the Bound To
dialog box.
18. In the Component Path field, select “DataSet <user_ds>” from the Component Path
column and then select “selectedIndex : Number” from the Schema Location column.
19. Enter the following code in the Actions panel:
next_button.addEventListener("click", nextBtnClick);
function nextBtnClick(evt_obj:Object):Void {
user_ds.next();
}
This code uses the DataSet.next() method to navigate to the next item in the DataSet
object’s collection of items. Since you had previously bound the
selectedIndex property
of the DataGrid object to the same property of the DataSet object, changing the current
item in the DataSet object changes the current (selected) item in the DataGrid object
as well.
20.Save the file, and select Control > Test Movie to test the SWF file.
The DataGrid object is populated with the specified items. Notice how clicking the
button changes the selected item in the DataGrid object.
DataSet class (Flash Professional only)
Inheritance MovieClip > DataSet
ActionScript Class Name mx.data.components.DataSet
The DataSet component lets you work with data as collections of objects that can be indexed,
sorted, searched, filtered, and modified.
The DataSet component functionality includes DataSetIterator, a set of methods for
traversing and manipulating a data collection, and DeltaPacket, a set of interfaces and classes
for working with updates to a data collection. In most cases, you don’t use these classes and
interfaces directly; you use them indirectly through methods provided by the DataSet class.