Frank, There's no .equals() in actionscript unless you implement it yourself. Without hearing more about the context, it's hard to tell whether Jitendra's data binding solution would work for this specific problem (data binding would effectively set the list selection to an object that is not in the list--I'm not sure what happens there), but you might run into a need for .equals() further down the line. We did, and since all of our VOs inherit from one VO base object, we just implement .equals() in these as necessary. It seems rather horrifying that there's no .equals() at first, but you don't really need it that often...
-- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -----Original Message----- From: frank_sommers <[EMAIL PROTECTED]> Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: [flexcoders] Java-like equals() method? Date: Sat, 11 Oct 2008 02:54:18 -0000 Hi, I've been searching for a good solution to implementing object equality. I'm familiar with ObjectUtil, etc., but it still makes things harder than they should be. It may be best to illustrate this with an example. Suppose I have a ComboBox with an ArrayCollection as a data provider. The ArrayCollection is populated with value objects from the server, e.g., User objects. Suppose that I have a Task class, and a Task may have an assignedToUser property, which is a User instance. When the someone selects a Task (say, in a master-detail view), I would like the ComboBox to set its selectedItem to the user for the given Task, i.e., combBox.selectedItem = myUser.assignedToUser. The problem is that no Task in the ComboBox's data provider and the User's assignedToUser property are ever equal using the == or === operators. So I would like to implement a custom equality for User, and have the ComboBox use that to set its selectedItem to the specified user. In Java, this is easily done by overriding the equals() and hashCode() methods of User. Any suggestions on how to achieve something similar in Flex would be much appreciated. Thanks, -- Frank