Why is the uid-getter/setter called (ArrayCollection)?
- by cowabunga1984
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!