获取下拉列表索引

private function selectIndex():void{
    var birthVisaDataProvider:ArrayCollection = ArrayCollection(this.d303_26.dataProvider);//获取下拉列表内容
    var d30326Index:int = this.getDropDownListSelectedIndex(birthVisaDataProvider,d301.d30126);//调用getDropDownListSelectedIndex函数获取索引
    this.d303_26.selectedIndex = d30326Index;
}

//获取下拉列表的索引函数
private function getDropDownListSelectedIndex(arrayCollection:ArrayCollection, defaultValue:String):int
{
    var len:uint = arrayCollection.length;
    var i:uint = 0;
    var index:int = 0;
    while(i < len) {
        var comboBoxDataP:ComboBoxData = arrayCollection.getItemAt(i) as ComboBoxData;
        if(comboBoxDataP.data == defaultValue) {
            index = arrayCollection.getItemIndex(comboBoxDataP);
            break;
        }
        i++;
    }
    return index;
}

 

posted @ 2013-09-12 10:28  High阔天空  阅读(553)  评论(0)    收藏  举报