Why is the uid-getter/setter called (ArrayCollection)?

Posted by cowabunga1984 on Stack Overflow See other posts from Stack Overflow or by cowabunga1984
Published on 2010-03-12T09:16:34Z Indexed on 2010/03/12 9:17 UTC
Read the original article Hit count: 318

Filed under:
|

Hi all,

if wrote the following code and do not understand why the trace returns "false":

function (with trace):

        import mx.controls.Alert;
        import mx.collections.ArrayCollection;

        public function runTest():void {
            var unique1:MyUniqueObject = new MyUniqueObject();
            unique1.id = 1;

            var unique2:MyUniqueObject = new MyUniqueObject();
            unique2.id = 2;

            var sameUniqueAsUnique1:MyUniqueObject = new MyUniqueObject();
            sameUniqueAsUnique1.id = 1;

            var collection:ArrayCollection = new ArrayCollection();
            collection.addItem(unique1);
            collection.addItem(unique2);

            trace(collection.contains(sameUniqueAsUnique1));
        }

MyUniqueObject-Class:

package
{
    import mx.core.IUID;

    [Bindable]
    public class MyUniqueObject implements IUID
    {
        public var id:int;

        public function get uid():String {
            return "MyUniqueObject." + id;
        }

        public function set uid(uid:String):void {
            //nothing to do here...
        }
    }
}

Any Ideas?

Cowabunga!

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3