Example
The following example creates a range of items in the DataSet component and modifies the
gradeLevel property of each item. To test this example, drag a DataSet component to the
Stage, and give it an instance name of
three new properties in the schema of the DataSet component by using the Schema tab in the
Component inspector. Name the new properties
the data types of String, Number, and Number respectively. Add a copy of the
DataBindingClasses
Libraries > Classes) and add the following ActionScript to Frame 1 of the main timeline:
my_ds.addItem({name:"Billy", id:104, gradeLevel:4});
my_ds.addItem({name:"Bobby", id:105, gradeLevel:4});
my_ds.addItem({name:"Carrie", id:106, gradeLevel:4});
my_ds.addItem({name:"Cathy", id:110, gradeLevel:4});
my_ds.addItem({name:"Mally", id:112, gradeLevel:3});
my_ds.addSort("name_id", ["name", "id"]);
my_ds.setRange(["Bobby", 105], ["Cathy", 110]);
while (my_ds.hasNext()) {
my_ds.gradeLevel = "5"; // Change all of the grades in this range.
my_ds.next();
}
my_ds.removeRange();
my_ds.removeSort("name_id");
for (var i=0; i<my_ds.length; i++) {
trace(my_ds.items[i].name + " > " + my_ds.items[i].gradeLevel);
}
See also
DataSet.applyUpdates()
DataSet.removeRange()
400
Components Dictionary
my_ds
compiled clip from the Classes common library (Window > Common
,
DataSet.hasNext()
,
DataSet.setRange()
. With the DataSet component selected, create
,
, and
name
id
gradeLevel
,
DataSet.next()
, and give them
,
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers