2010-08-23 105 views
1

我有一个TabNavigator组件,它在运行时添加它们时没有显示它的子组件。TabNavigator not showing children

请问有没有办法解决这个问题?

我做的时刻如下:

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; 

对不起球员没有给予足够的细节。 tabNavigator位于一个容器中,因为我认为它不相关,所以我没有添加代码。

我替换了SimpleComponent by MyComponent在上面的代码中。 MyComponent只是带有文本字段和标签的另一个HBox

谢谢。

+0

在当前的代码片段,从不添加的标签导航作为其母公司的组成部分。我不确定这是否是您复制和粘贴的副作用或实际代码存在的问题。如果您可以提供我们可以运行的完整代码;这将是有益的。 – JeffryHouser 2010-08-23 18:46:19

+0

SimpleComponent是Spark组件。如果没有Halo容器包装,Spark组件不能添加到TabNavigator子项中。 – 2DH 2010-08-23 18:46:47

回答

0

尝试把这样的:

tabNavigator.addChild(myComponent); 

tabNavigator.selectedChild = 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;