views:

50

answers:

1

For example i have an ArrayCollection, and i want to find persons with telephone begines with "944" how can i do this?

<mx:ArrayCollection id="arrColl" >
    <mx:source>
        <mx:Array>
            <mx:Object telephone="944768" subscriber="Smith P.T."/>
            <mx:Object telephone="944999" subscriber="Peterson Q.T."/>
         </mx:Array>
        </mx:source>
    </mx:ArrayCollection>  
+2  A: 

Are you displaying this ArrayCollection as a dataprovider to a user somewhere? If so, then you can set arrColl.filterFunction property of the collection and then call arrColl.refresh()

Example filter function:

function filterTelephoneBeginsWith(item:Object):Boolean
{
   var beginsWithString:String = "944";

   return String(item["telephone"]).indexOf(beginsWithString) == 0;
}

If you're just trying to get an Array of all the ones beginning with 944, you can use the same function-- just apply it to every item in arrColl to determine whether or not it should be in your resulting Array.

btlachance