Description
Method; returns a new iterator for this collection; this iterator is a clone of the current iterator
in use, including its current position in the collection. This method is mainly for advanced
users who want access to multiple, simultaneous views of the same collection.
Example
The following example uses
whose
field contain the value
name
pointing to Bobby's record, the main iterator of
Billy.
To test this example, drag a DataSet component to the Stage, and give it an instance name of
. Add two properties,
student_ds
DataSet component by using the Schema tab of the Component inspector. If you don't
already have a copy of the
the compiled clip from the Classes library (Window > Common Libraries > Classes). Add the
following ActionScript to Frame 1 of the main timeline:
import mx.data.to.ValueListIterator;
student_ds.addItem({name:"Barry", id:103});
student_ds.addItem({name:"Bobby", id:105});
student_ds.addItem({name:"Billy", id:107});
var myIterator:ValueListIterator = student_ds.getIterator();
myIterator.sortOn(["name"]);
myIterator.find({name:"Bobby"}).id = "999";
trace(student_ds.currentItem.name + " [" + student_ds.currentItem.id +
"]");
// Billy [107]
student_ds.addSort("id", ["name", "id"]);
if (student_ds.find({name:"Bobby", id:999})) {
student_ds.locateById(student_ds.getItemId());
trace(student_ds.currentItem.name + " [" + student_ds.currentItem.id +
"]");
// Bobby [999]
} else {
trace("We lost Billy!");
}
372
Components Dictionary
to search for an item in the current collection
DataSet.find()
. Even though the
"Bobby"
(data type: String) and
name
DataBindingClasses
myIterator
still points to the last record,
student_ds
(data type: Number) to the
id
compiled clip in your library, drag a copy of
iterator is
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers