Create a variable to hold the current selection index

private var comboCurrentSelectedIndex:int = -1;

add a change event to the comboBox

<mx:ComboBox id="myComboBox" change="myComboBoxChanged()"/>

keep the selected index current

private function myComboBoxChanged():void
{
  comboCurrentSelectedIndex = myComboBox.selectedIndex;
}

When the new data comes in, set the selectedIndex of the comboBox to
the saved index

myComboBox.selectedIndex = comboCurrentSelectedIndex;


--- In [email protected], "nehavyas13" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> I am using a combo box and its dataprovider is an arrayCollection
> (dp1.arr1, dp1 is a actionscript class and arr1 is a global
> arraycollection for class). The data is refreshed every minute. Hence,
> in the dp1 class, refreshData() method gets called every minute and
> populates a new arraycollection arr2 with the data everytime. And then
> lastly arr1 points to arr2. (ie. in code I write arr1=arr2). This
> works fine.
> 
> But the problem is say if I had selected "value 3" in  combo box. Now
> when data refreshes and arr1=arr2, the combobox shows "value 1" i.e
> the 1st value in the array. 
> 
> What I want is the data in the combo box should be refreshed every
> min. and also the selected value should not change. The data is bound
> to change everytime. i.e some values might be deleted and some new
> values might be added.
> 
> Can somebody please provide me with an example for this or provide a
> solution to my above problem so that the seleceted value in combo box
> remains same?
> 
> 
> Thanks
>


Reply via email to