tags:

views:

25

answers:

1

I have a TabNavigator component which is not showing its children when adding them at runtime.

Is there a way around this please?

I'm doing the following at the moment:

var tabNavigator:TabNavigator = new TabNavigator();

// etc.

parentHBoxContainer.addChild(tabNavigator);

 // etc.

// Custom component with nothing special in it

// Trigger on a button click (Add)
var myComponent:MyComponent = new MyComponent();

var nextTabIndex:int = tabNavigator.getChildren().length;
tabNavigator.addChild(myComponent);

// I see some text flashing but the current tab stays the same
// No text is added
tabNavigator.validateNow(); 

tabNavigator.selectedIndex = nextTabIndex;

Sorry guys for not giving enough details. The tabNavigator is inside an HBox container, I didn't add the code because I thought it would be irrelevant.

I replaced SimpleComponent by MyComponent in the code above. MyComponent is just another HBox with a textfield and a label.

Thanks.

A: 

Try to put this:

tabNavigator.addChild(myComponent);

tabNavigator.selectedChild = myComponent;

instead of this:

var nextTabIndex:int = tabNavigator.getChildren().length;
tabNavigator.addChild(myComponent);

// I see some text flashing but the current tab stays the same
// No text is added
tabNavigator.validateNow(); 

tabNavigator.selectedIndex = nextTabIndex;
2DH