User Guide
DataSet.first() 369
DataSet.first()
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
dataSetInstance.first()
Returns
Nothing.
Description
Method; makes the first item in the current view of the collection the current item. Which
items are in the current view depends on any current filter and range settings.
Example
The following code positions the data set inventory_ds at the first item in its collection,
and then displays the value of the
price property contained by that item using the
DataSet.currentItem property.
inventory_ds.first();
trace("The price of the first item is:" + inventory_ds.currentItem.price);
The following example iterates over all of the items in the current view of the collection
(starting at its beginning) and performs a calculation on the
price property of each item.
my_ds.addItem({name:"item a", price:16});
my_ds.addItem({name:"item b", price:9});
my_ds.first();
while (my_ds.hasNext()) {
my_ds.currentItem.price *= 0.5; // Everything's 50% off!
my_ds.next();
}
for (var i in my_ds.items) {
trace(my_ds.items[i].name + ": " + my_ds.items[i].price);
}
See also
DataSet.last()