Setting default Index for a Drop Down List in flex 4

2k Views Asked by At

I have a drop down list that gets its data from a php web service method.This response is smthing like :

array('id'=>integer,'name'=>'lin')

When the page loads, I want to set the selected index to "lin" initially. How do I do this ?

1

There are 1 best solutions below

3
JHK On BEST ANSWER

you just need to set selectedIndex property of dropdownlist control.

ex.

dwl.selectedIndex = 1; // "Index of "lin"

you should do this.

var iIndex:int;

for(var i:int = 0; i < arrResponse.length; i++)
{

       // if(Array(arrResponse[i])[1] == "lin")

       if(Array(arrResponse[i]).name == "lin") {
            iIndex = i;

       }

}

dwl.selectedIndex = iIndex;