User Guide

Iterator interface (Flash Professional only) 441
Iterator interface (Flash Professional only)
ActionScript Class Name mx.utils.Iterator
The Iterator interface lets you step through the objects that a collection contains.
Method summary for the Iterator interface
The following table lists the methods of the Iterator interface.
Iterator.hasNext()
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
iterator.hasNext()
Returns
A Boolean value that indicates whether there are (true) or are not (false) more instances in the
iterator.
Description
Method; indicates whether there are more instances in the iterator. You typically use this method
in a
while statement when looping through an iterator.
Example
The following example uses the hasNext() method to control looping through the iterator of
items in a collection:
on (click) {
var myColl:mx.utils.Collection;
myColl = _parent.thisShelf.MyCompactDisks;
var itr:mx.utils.Iterator = myColl.getIterator();
while (itr.hasNext()) {
var cd:CompactDisk = CompactDisk(itr.next());
var title:String = cd.Title;
var artist:String = cd.Artist;
trace("Title: "+title+" Artist: "+artist);
}
}
Method Description
Iterator.hasNext() Indicates whether the iterator has more items.
Iterator.next() Returns the next item in the iteration.
CHAPTER 6
Components Dictionary