Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > Collection interface > Collection.contains() | |||
Flash Player 7.
Flash MX Professional 2004.
collection.contains(item)
item The object whose presence in the collection is to be tested.
A Boolean value of true if the collection contains item.
Method; indicates whether the collection contains the specified item. For Flash to consider the objects as equal, they must refer to the same object. If item is a different object, Collection.contains() returns false, even if the object's properties are all equal.
The following example calls contains():
var myColl:mx.utils.Collection;
myColl = _parent.thisShelf.MyCompactDiscs;
var itr:mx.utils.Iterator = myColl.getIterator();
while (itr.hasNext()) {
var cd:CompactDisc = CompactDisc(itr.next());
var title:String = cd.Title;
var artist:String = cd.Artist;
if(myColl.contains(cd)) {
trace("myColl contains " + title);
}
else {
trace("myColl does not contain " + title);
}
}
Flash CS3