2010-08-23 234 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;