<mx:Panel title="TabNavigator Container Example" height="90%" width="90%" paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> <mx:TabNavigator id="tn" width="100%" height="100%"/> <mx:Label width="100%" color="blue" text="Programmatically add Tab buttons"/> <mx:HBox> <mx:Button label="Add A Tab" click="addTab()"/> <mx:Button label="Remove A Tab" click="removeTab()"/> </mx:HBox> </mx:Panel>
<mx:Script> <![CDATA[ import mx.controls.Button; import mx.controls.Label; import mx.containers.VBox; public var numChild:Number = 0; public function addTab():void { var newVBox:VBox = new VBox(); var newLabel:Label = new Label(); numChild = tn.numChildren + 1; newVBox.label = "Panel " + numChild; newLabel.text = "TabNavigator container panel " + numChild; newVBox.addChild(newLabel); tn.addChild(newVBox); } public function removeTab():void { if(tn.numChildren > 0){ numChild --; tn.removeChildAt(numChild); } } ]]> </mx:Script>

