10 Replies Latest reply on Apr 30, 2009 4:03 PM by Flex harUI

    How to check if object in one list exists in another list?

    Miggl Level 1

      I have two ArrayCollections: ListA and ListB. They both contain the same type of objects. How can I successfully check if an object in ListA also exists in ListB?

       

      My attempts (so far unsuccessful) went like this:

      if (-1 != ListB.getItemIndex(ListA.getItemAt(0)))
      {
           //then do successful action here
      }
      else
      {
           //do failure action here
      }
      

       

      This check always seems to result in -1, even if the first item in ListA did indeed exist in ListB.

      Thoughts?