Often when you programmatically  assign a dataProvider to a control, you
need to wait for the control to render before operating on its visual
elements.  So save the desired index from the loop, then use callLater() to
actually set the selectedIndex.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of moevydot...@ymail.com
Sent: Sunday, March 08, 2009 6:24 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] DropDown selectedIndex problem

 

Hello @ all,
I want to select a specific part with selectedIndex. But it dont works :( It
selects all the time the first one in the list.

Can someone give me a help? There its the code... 

Thanks Michael

Code:
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;

[Bindable]
public var initSubjectableList:ArrayCollection = new ArrayCollection();
public var licenceID:String;

private function getSubjectDataList(evt:ResultEvent):void {
var count:Number = 0;
var _data:Array;
var _data2:Array;

for( count = 0; count < evt.result.id.length; count++)
{
//create array for drop down
_data = [{ID: evt.result.id[count], label: evt.result.name[count]}];
_data2 = _data.concat(_data2);
initSubjectableList = new ArrayCollection(_data2);

if(evt.result.id[count] == licenceID) {
editLicence.selectedIndex = count;

mx.controls.Alert.show("ID");
mx.controls.Alert.show(evt.result.id[count]); 
}
}
}

]]>
</mx:Script>



Reply via email to