Doesn't it have to be stateCB.selectedIndex = i; Cheers, Ralf.
On 2/2/07, malik_robinson <[EMAIL PROTECTED]> wrote:
Hi, I am trying to set the selectedIndex of my "U.S. States" custom combo box equal to what the user has stored in their record in our database. Someone posted a link to a similar tutorial, but I could not get it to work and I think it seems to be slightly different than what I am doing. When the screen loads, the state the user is associated with should be selected, otherwise set the selectedIndex equal to 0. As of now it does not select anything it seems the condition where I test for equality fails and I always get the selectedIndex set to 0. *The code:* *public function** initStateCB(employeeStateId:Number):void** {* for ( var i:int=0; i< stateCB.dataProvider.length; i++ ) { if( employeeStateId == stateCB.dataProvider[i].stateId ) { stateCB.selectedIndex = employeeStateId ; } else { stateCB.selectedIndex = 0; } } *} **// close function* ** <mx:FormItem label="State:"> <comp:StateCombo id="stateCB" dataProvider="{model.stateList}" labelField="stateName" creationComplete="initStateCB( model.employeeProfileArray[0].stateId)"/> </mx:FormItem>
-- Ralf Bokelberg <[EMAIL PROTECTED]> Flex & Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35