I think I have found a bug, or at elast I am getting behaviour that I cant
explain, although I am new to Flex so I am posting here to make sure it is not
me.....

When running this code I would expect that if you click on the remove tab
button then only two tabs would be shown, but by setting the selectedIndex
property I would expect that the second tab would be highlighted.

The add tab button does somethign very simmilar, in as much as by setting the
selectedIndex to 2, the thrid tab is ALWAYS highlighted.

However, when using the remove tab button, the second tab is ONLY hightlighted
when you manually select the first tab BEFORE clicking the button. IE run this
code and use the remove tab button with any tab other than Alabama selected and
you will see that the Alaska tab is not highlighted (in fact no tab is
highlighted). When you select the Alabama tab and then click remove tab button
then the code works as expected.

Is this a bug?



<?xml version="1.0"?>
<!-- Simple example to demonstrate the TabBar layout -->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >

<mx:Script>
<![CDATA[

var STATE_ARRAY:Array = [{label:"Alabama", data:"Montgomery"},
{label:"Alaska", data:"Juneau"},
{label:"Arkansas", data:"LittleRock"}
];

public function clickMe() {
// Now remove one of the tabs, and set to highlight Alaska
fred.dataProvider = [{label:"Alabama", data:"Montgomery"},
{label:"Alaska", data:"Juneau"}
];
var myIndex:Number = fred.selectedIndex;
fred.selectedIndex = 1;
}

public function addMe() {
// Now add extra tabs and set to higlight B
fred.dataProvider = [{label:"Alabama", data:"Montgomery"},
{label:"Alaska", data:"Juneau"},
{label:"B", data:"er"},
{label:"C", data:"fg"}
];
var myIndex:Number = fred.selectedIndex;
fred.selectedIndex = 2;
}


]]>
</mx:Script>

<mx:Panel title="Tab Bar Panel" width="400" height="200">

<mx:TabBar id="fred">
<mx:dataProvider>
{STATE_ARRAY}
</mx:dataProvider>
</mx:TabBar>
<mx:Button click="clickMe()" label="Remove Tab" />
<mx:Button label="Add Tab" click="addMe()"/>
</mx:Panel>

</mx:Application>