Hi, I am new to actionscript and not quite sure how to implement that solution you suggested. It looks like the way to go because I do want to always have the right state selected when the detail screen first loads so I presume that is where the binding kicks in.
Here is what I did in the code which I think is wrong how I am referencing the array in the parameter public function getStateIndex(employeeStateId:Number, model.employeeProfileArray[0]:Array):void { var selectedIndex : int = 0; for ( var i:int=0; i< stateCB.dataProvider.length; i++ ) { if( getStateIndex(employeeStateId:== stateCB.dataProvider[i].stateId ) { selectedIndex = getStateIndex(employeeStateId:; } } stateCB.selectedIndex = selectedIndex; <comp:StateCombo id="stateCB" selectedIndex="{ getStateIndex( employeeStateId:Number, model.employeeProfileArray[0]:Array ) }" dataProvider="{model.stateList}" labelField="stateName"/> I am using Cairngorm 2.1 and it is actually working pretty well for me, so is there a way to elegantly bind this to the ModelLocator? The array is bound to the ModelLocator --- In flexcoders@yahoogroups.com, "Ralf Bokelberg" <[EMAIL PROTECTED]> wrote: > > That's probably because the creationComplete event is called just once. > What if you use binding instead? > > selectedIndex={ getStateIndex( *employeeStateId:Number, dataProvider:Array*) } > > Cheers, > Ralf. > > > > On 2/2/07, malik_robinson [EMAIL PROTECTED] wrote: > > > > > > Hi, > > > > The code works the first time around. First time around meaning click > > an employee from the datagrid and the screen changes to a detail view of > > that employee. > > > > For some reason every user I bring up after the first user has the same > > "State (Arizona) for example" selected thereafter. The first time > > around it works, but then when I go back to the employee list screen, > > and click a different employee, the detail form populates with all the > > right info like (firstName, lastName, email, city, zip), but the state > > drop down has the value of the state the other user is associated with > > (Arizona). > > > > Its as if the code runs correctly once but when you click a different > > user the approriate state does not load, it just has the value from the > > prior user. Almost as if once the code runs once, and its being cached > > or something. All the other fields load correctly as I view each users > > detail view. > > > > I hope I am making sense. > > > > -M > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, "Ralf > > Bokelberg" ralf.bokelberg@ > > wrote: > > > > > > Ah sorry, i haven't read the text ;) > > > What if you try it like that: > > > > > > var selectedIndex : int = 0; > > > for ( var i:int=0; i< stateCB.dataProvider.length; i++ ) { > > > if( employeeStateId == stateCB.dataProvider[i].stateId ) { > > > selectedIndex = employeeStateId ; > > > } > > > } > > > stateCB.selectedIndex = selectedIndex; > > > > > > Cheers, > > > Ralf. > > > > > > -- > > > Ralf Bokelberg ralf.bokelberg@ > > > Flex & Flash Consultant based in Cologne/Germany > > > Phone +49 (0) 221 530 15 35 > > > > > > > > > > > > > -- > Ralf Bokelberg [EMAIL PROTECTED] > Flex & Flash Consultant based in Cologne/Germany > Phone +49 (0) 221 530 15 35 >