tags:

views:

52

answers:

1

I am creating a lot of dynamic flex components like RadioButton, Combo Box, CheckBox.

if(type=="mx.controls.CheckBox"){
            //if(rep.currentIndex<5){
                for each(j in x){
                k=createNewInstanceOfClass(rep.currentItem.type);           
                k.id="radioGroup"+rep.currentItem;
                k.label=j.linkname;
                k.data=j.linkname;
                linkPanel[rep.currentIndex].addChild(DisplayObject(k));
                }

MXML

<mx:Panel layout="horizontal" id="linkPanel" title="Evaluation" fontWeight="bold" height="100%" backgroundColor="0xFFF7E6"
                                borderThicknessLeft="0" borderThicknessRight="0" cornerRadius="10" headerHeight="20" dropShadowEnabled="false" roundedBottomCorners="true" verticalScrollPolicy
                                ="off" horizontalScrollPolicy="off" headerColors="[#ffffff,#ffffff]" width="100%">
                                <mx:Form>
                                <mx:FormItem paddingLeft="2" paddingTop="2" paddingBottom="2">
                                    <mx:Repeater id="rep2" dataProvider="{sendToActionScript(rep.currentItem.link)}" />
                                </mx:FormItem>
                                </mx:Form>
                            </mx:Panel>

When i click on Submit finally i need to get all the selected Values in each question. All the components are dynamically created at runtime.

+1  A: 

You can list the children of linkPanel with getChildren() when looping through them, read the "selected" property

        public function test():void {
            for each ( var obj:Object in linkPanel.getChildren()) {
                if( obj is RadioButton) {
                    Alert.show( (obj as RadioButton).selected.toString());
                }

            }
        }

If you are creating a list of radio buttons belonging to a group, look into "selectedValue" for this group

<mx:RadioButtonGroup id="rbg" />
<mx:RadioButton id="answer1" group="{rbg}" label="Answer 1" />

public function test():void {
    Alert.show( rbg.selectedValue.toString())
}
TypeError: Error #1006: getChildren is not a function. When i click on the submit button, i get this error after selecting the RadioButton.
In my example linkPanel is a Panel element id.What is it on yours?
Its panel only in my example
getChildren is available in all the Containers (Accordion, Box, Canvas, Form, FormItem, LayoutContainer, Panel, Tile, ViewStack).Where are you adding the Radio buttons? That's where you want to call getChildren()
Added the MXML code where the components are created.
Why don't you just addChild() on the linkPanel itself (as opposed to linkPanel[whatever])
I could not get you, can you show me or shall i post you the entire code.