0

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

4

1 回答 1

1

我认为您正在寻找的是Operator Overloading,根据这篇文章,您似乎无法在 Flex 中做到这一点。但是,您可以在自定义组件中编写一个equals()方法来比较两者。

于 2012-04-19T20:24:12.167 回答