Actionscript 3 如何以编程方式更改spark组合框中突出显示的项

Actionscript 3 如何以编程方式更改spark组合框中突出显示的项,actionscript-3,apache-flex,flex4,flex3,flex4.5,Actionscript 3,Apache Flex,Flex4,Flex3,Flex4.5,我想以编程方式更改spark组合框中突出显示的项。 当使用所选项目打开组合框弹出窗口时,它在弹出窗口中显示为突出显示的颜色。现在打开弹出窗口时,我通过设置selectedIndex和selectedItem属性以编程方式更改了所选项目。文本输入随给定的所选项目而更改,但突出显示的颜色仍显示以前的值。如何将突出显示的项目更改为选定项目。 有谁能提供解决这个问题的办法吗 public class AutoSortComboBox extends ComboBox{ public fun

我想以编程方式更改spark组合框中突出显示的项。 当使用所选项目打开组合框弹出窗口时,它在弹出窗口中显示为突出显示的颜色。现在打开弹出窗口时,我通过设置selectedIndex和selectedItem属性以编程方式更改了所选项目。文本输入随给定的所选项目而更改,但突出显示的颜色仍显示以前的值。如何将突出显示的项目更改为选定项目。 有谁能提供解决这个问题的办法吗

public class AutoSortComboBox extends ComboBox{



    public function AutoSortComboBox ():void    {   
                super();   
    }
    protected function sortDataProvider(descending:Boolean):void{

                var arrColl:ArrayCollection = this.dataProvider as ArrayCollection;
                var selectedItem:Object = this.selectedItem as Object;
                this.selectedIndex = -1;
                var dataSortField:SortField = new SortField();
                dataSortField.name = "label";
                dataSortField.numeric = false;
                dataSortField.descending = descending;
                /* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
                var numericDataSort:Sort = new Sort();
                numericDataSort.fields = [dataSortField];
                arrColl.sort = numericDataSort;
                arrColl.refresh();
                if(selectedItem != null)
                {
                    for(var i:int=0;i<arrColl.length;i++)
                    {
                        if(selectedItem.label == arrColl[i].label)
                            this.selectedIndex = i;
                    }
                    this.selectedItem = selectedItem;
                }
     }
  }
公共类AutoSortComboBox扩展了ComboBox{
公共函数AutoSortComboBox():void{
超级();
}
受保护函数sortDataProvider(降序:布尔值):void{
var arrColl:ArrayCollection=this.dataProvider作为ArrayCollection;
var selectedItem:Object=this.selectedItem作为对象;
this.selectedIndex=-1;
var dataSortField:SortField=new SortField();
dataSortField.name=“label”;
dataSortField.numeric=false;
dataSortField.descending=降序;
/*创建排序对象,并将先前创建的SortField对象添加到要排序的字段数组中*/
var numericDataSort:Sort=new Sort();
numericDataSort.fields=[dataSortField];
arrColl.sort=numericDataSort;
arrColl.refresh();
如果(selectedItem!=null)
{

对于(var i:int=0;i

FocusManager.SetFocus(DisplayObject)


我不清楚您是问如何在Spark组合框中设置高亮显示项的样式,还是问如何更改高亮显示的项。很抱歉,我不清楚我是问如何更改高亮显示的项ComboBox changeHighlightedSelection中有一个内部方法我想调用changeHighlightedSelection方法。如何调用该方法以更改突出显示的选择项稍后使用此调用尝试(函数():void{Combobox.selectedItem=ItemFromCombobox});嘿,Raja Jaganathan,谢谢你的解决方案。我尝试了callLater,你已经给出了。它可以工作了,但问题是我现在有两个突出显示的项目,一个是以前选中的项目,另一个是新选中的项目。如何删除以前突出显示的项目。我无法在这里发布屏幕截图,否则你可能会更清楚您需要重新访问for循环语句以选择带有out-BREAK语句的项,否则您的arraycollection标签值可能会重复。
 Combobox.selectedItem = ItemFromCombobox