Flex 3 - Style not applying completely on dynamically created tabs in TabNavigator
When I create a tab dynamically via ActionScript, the style for the newly created (and selected) tab get applied to the skins, but not the text, unless I click on another tab and then click back to it.
ActionScript
private function clickAddTabHandler(event:Event):void{
var vbox:VBox = new VBox;
var tab:Canvas = new (Canvas);
vbox.label = "Select Location";
vbox.addChild(tab);
tabBar.addChild(vbox);
tabBar.selectedIndex = tabBar.numChildren-1;
}
MXML
<mx:TabNavigator id="tabBar" width="100%" height="100%" tabStyleName="tabNavigator" selectedTabTextStyleName="tabNavigatorSelected" tabHeight="19">
CSS
.tabNavigator
{
disabledSkin: Embed(source="assets/skins/TabBar-tab_disabledSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
downSkin: Embed(source="assets/skins/TabBar-tab_downSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
overSkin: Embed(source="assets/skins/TabBar-tab_overSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
upSkin: Embed(source="assets/skins/TabBar-tab_upSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
selectedDisabledSkin: Embed(source="assets/skins/TabBar-tab_selectedDisabledSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
selectedUpSkin: Embed(source="assets/skins/TabBar-tab_selectedUpSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
selectedOverSkin: Embed(source="assets/skins/TabBar-tab_selectedUpSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
selectedDownSkin: Embed(source="assets/skins/TabBar-tab_selectedUpSkin.png",
scaleGridTop=1,
scaleGridLeft=20,
scaleGridBottom=18,
scaleGridRight=32);
textAlign: left;
paddingLeft: 20;
paddingRight: 20;
fontSize: 11;
fontFamily: Helvetica Neue;
color: #FFFFFF;
textRollOverColor: #FFFFFF;
}
.tabNavigatorSelected
{
textAlign: left;
paddingLeft: 20;
paddingRight: 20;
fontSize: 11;
fontFamily: Helvetica Neue;
开发者_如何学JAVA color: #135F9E;
textRollOverColor: #135F9E;
textSelectedColor: #135F9E;
}
Always with css I suggest using the style explorer. It has always helped me get correct styles.
http://examples.adobe.com/flex3/consulting/styleexplorer/Flex3StyleExplorer.html
PS, use the "Code Sample" button to better format your code, its the one labled 101010 by the quotes and the image icon at the top of the editor, or just indent it all with 4 spaces. It will make it easier for everyone to read.
精彩评论