Actionscript doesn't implement an equivalent to java's .hashCode() and
.equals() pattern; whether or not that's a good thing is an exercise best
left to the reader - and a source of a few heated discussions around these
parts, too ;-)

I've written a little utility class you can use if you need a quick way to
test for equality for the purposes of comboboxes or lists:

http://flex.joshmcdonald.info/2008/10/selecting-right-value-from-combobox-or.html

-Josh

On Tue, Nov 25, 2008 at 7:31 AM, erdal <[EMAIL PROTECTED]> wrote:

>  I think I am misinterpreting the uid property usage
> http://livedocs.adobe.com/flex/3/html/help.html?content=about_dataproviders_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";
> 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>
>
>
> 
>



-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Like the cut of my jib? Check out my Flex blog!

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]
:: http://flex.joshmcdonald.info/
:: http://twitter.com/sophistifunk

Reply via email to