Collection.contains()

Availability

Flash Player 7.

Edition

Flash MX Professional 2004.

Usage

collection.contains(item)

Parameters

item The object whose presence in the collection is to be tested.

Returns

A Boolean value of true if the collection contains item.

Description

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.

Example

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