Hopefully flex has been around long enough that some of you flash guru's know how to use it.
I'm trying to get the index of an object inside an array collection, but the API information states that contains and getitemindex only return a result based on == of the provided object.
Given that the object does not appear to have an overridable equals method, and I can't find an IComparable interface, does anyone know if I can control what values the searching is performed on?
Given a 'Tag' object, which has a id, parent, desc, etc, and placed into an ArrayCollection, I want to get the tag associated with the tag id:
Code:
// This is in a graph object, also containing a get item index and get item at
public function contains(item:Tag):Boolean
{
return this.tags.contains(item);
}
The problem here is, unless the item has explicitly been defined, I can't get the contains result.
So, running something like:
Code:
// Graph has already had this tag added
var tag:Tag = new Tag();
tag.setID(1);
trace(graph.contains(tag)); // This returns false
tag.setParentID(-1);
tag.setDesc("No Desc");
tag.setTitle("No Title");
trace(graph.contains(tag)); // This returns true, now that all the fields have been added and are the same (assumably)
I want to convert my tag collection into a vertex collection, so I can easily add and remove neighbours from my adjacency graph. Since I won't know what the neighbour relationships will be, this contains method will not work.
Any ideas how to control the search behaviour of the contains/getitemindex values on the array collection? I was thinking of a compareTo, but like I said - no IComparable interface