MindlessRouse
MindlessRouse

Reputation: 197

Custom component comparison in flex

I have a custom component called Tag

package bin {
  public class Tag  {
    public var count:int;
    public var text:String;

    public function Tag() {}
  }
}

I have a bunch of these tags in a two arrays. I want to be able to call

arr0.indexOf( arr1[0] )  //line 1
// or 
arr0[0] == arr1[0]       //line 2

and only have the text field be compared. ie

tag{text:"hi", count:0} == tag{text:"hi", count:5}

Even though the counts differ the above result would be true, likewise if the two tags are in the different lists I want them to match up to each other as would in line 1

In java the solution would be to implement the comparable interface and overwrite the compare method to suit my needs. I could not find any documentation on such a solution in flex. Nor did my attempts at making a compare method work.

I am using Flex 3 fyi

Upvotes: 0

Views: 109

Answers (1)

Travesty3
Travesty3

Reputation: 14479

I think what you're looking for is Operator Overloading, and according to this post, it doesn't look like you can do that in Flex. But, you can write an equals() method in your custom component to compare the two.

Upvotes: 1

Related Questions