I think I am misinterpreting the uid property usage
http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataprovid\
ers_8.html
<http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataprovi\
ders_8.html>
In a BlazeDS application I am using an ArrayCollection of items (VOs)
returned from the server. I thought when I implement the iuid interface,
that will guide flex framework for deciding on objects equality and then
I can use the getItemIndex(Obj) kind of functions. But It didn't work.
So I wrote this simple test.
I was expecting to see person1 and clone1 would pass equality test. But
they didn't. What am I missing ? I am actually looking for something I
can use like Java equals.
-- File Person.as
------------------------------------------------------------------------\
-----------------
package
{
import mx.core.IUID;
public class Person implements IUID {
public var _uid:String;
public function get uid(): String {
return _uid;
}
public function Person() {
}
public function set uid(value: String): void {
_uid=value;
}
}
}
-- File test.mxml --------------------------------------------
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="vertical">
<mx:Script>
<![CDATA[
public function onClick():void
{
var person1:Person = new Person();
var person2:Person = new Person();
var clone1:Person = new Person();
person1.uid = "1";
person2.uid = "2";
clone1.uid = "1";
trace("UIDs are person1:"+person1.uid+" person2:"+person2.uid+"
clone1:"+clone1.uid);
trace("Is person1 and person2 equal ? " + (person1 == person2));
trace("Is person1 and twin1 equal ? " + (person1 == clone1));
}
]]>
</mx:Script>
<mx:Button label="run equality test" click="onClick()" />
</mx:Application>