Each time you use {} you create a different object, so the two
collections have different objects with the same data.  Contains just
sees if the reference to an object is in the collection and doesn't
investigate internal properties.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of freska
Sent: Monday, October 01, 2007 11:29 PM
To: [email protected]
Subject: [flexcoders] arraycollection contains() method



Hi there,
I want to compare two arraycollection and take the different items
out. I tried using contains() method to check if the first item of
arraycollection arrayControl is in arraycollection arrayColPref, but
it just doesn't work. I mean, it is supposed to say "True" instead of
"False". So, here's my code. Please show me where I did it wrong.

[Bindable]
public var arrayControl:ArrayCollection = new
ArrayCollection([{name:"Message", data:"colMessage"}, {name:"Assigned
to", data:"colAssignedto"}, {name:"Start date", data:"colStartdate"},
{name:"Due date", data:"colDuedate"}, {name:"Status",
data:"colStatus"}, {name:"Priority", data:"colPriority"},
{name:"Posted by", data:"colPostedby"}]);

[Bindable]
public var arrayColPref:ArrayCollection = new
ArrayCollection([{name:"Message", data:"colMessage"},
{name:"Priority", data:"colPriority"}, {name:"Assigned to",
data:"colAssignedto"}, {name:"Status", data:"colStatus"}]);

public function isDuplicate():void {
var bool:Boolean = arrayColPref.contains(arrayControl.getItemAt(0));
Alert.show(String(bool));
}



 

Reply via email to