Yes, as Sam says. To use getItemIndex(), you must pass in a reference to an item in the collection.
Tracy Spratt, Lariat Services, development services available _____ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Sam Lai Sent: Sunday, April 26, 2009 3:59 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] getItemIndex ......returning -1 Flex is looking for a string in the array with the value 'specific course name'. In your arraycollection though, you have objects (not strings), which within them hold multiple strings (TITLE, DESC, REQ). The only way to match again the title field of every object in the array is to use a for loop, e.g. var index:int = -1; for (var i:int = 0; index < courses.length; index++) { if (courses.getItemAt(index).TITLE == "specific course name") { index = i; break; } } if (index < 0) trace("no course found by that name"); else trace("course found"); 2009/4/26 kpjj31 <joe.g.james@ <mailto:joe.g.james%40kp.org> kp.org>: > What am I doing wrong. Thanks. > > private function getcoursesResult(event:ResultEvent):void{ > > courses = new ArrayCollection (event.result.COURSELIST as Array); > > var newindex:int = courses.getItemIndex('specific course name'); > > courses_datagrid.selectedIndex=newindex; > } > > arraycollection example... > > COURSELIST > + 0 > - 1 > TITLE : 'specific course name' > DESC : '' > REQ : '' > > > > > > > > > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups. <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: https://share. <https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e6 2079f6847> acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: http://www.mail- <http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo> archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links > > > >