2012-10-08 14 views
0

我有一個基於問題列表的Flex移動應用程序,根據需要哪種響應生成一組控件,這是輸入窗體。Actionscript獲取多個HGroup中的控件的值

結構是

Group 
-----Hgroup 
-----------Question1, CheckBox, TextInput 
-----Hgroup 
-----------Question2, CheckBox, TextInput 
-----Hgroup 
-----------Question3, CheckBox, TextInput 
-----Hgroup 
-----------Question4, CheckBox, TextInput 
end group 

我如何遍歷在ActionScript中組,到HGroup和返回的值,在這個例子中,複選框和TextInput?

我有很多例子如何確定容器中的控件類型,而不是如何檢索值。提前

感謝

+0

豈不是要快得多直接解決,而不是通過組元素與需要投每個控制循環的控制? – AlBirdie

回答

0

要循環和類型檢查使用:

for (var i:int; i < hGroup.numElements; i++) { 
    var child:DisplayObject = hGroup.getElementAt(i); 

    if (child is TextInput) { 
     var textInput:TextInput = child as TextInput; 
     // do your stuff 
    } 
    else if (child is CheckBox) { 
     var checkBox:CheckBox = child as CheckBox; 
     // do your stuff 
    } 
} 
+0

謝謝Max。就是我以後的樣子。 –