mx:RadioButtonGroup给出选择null ..为什么?

时间:2011-02-21 05:28:27

标签: flash flex actionscript-3

我有radiobutton组,当我添加radiobutton,事件然后它的选择为null,我调试它并在mx得到它:RadioButtonGroup,numRadioButtons是0 ..为什么?以及如何设置其选择。

public function AddRadioButton(elxRdButton:RadioButton):void
            {
                elxRdButton.group = id_RdGroup;
                elxRdButton.groupName = "id_RdGroup";
                if (elxRdButton.selected)
                {
                    id_RdGroup.selection = elxRdButton;
                    id_RdGroup.selectedValue = elxRdButton.value;
                }
                trace(id_RdGroup.selectedValue); // gives null
            }
        ]]>
    </fx:Script>
    <mx:RadioButtonGroup id="id_RdGroup"
                         change="id_RdGroup_changeHandler(event)"/>

1 个答案:

答案 0 :(得分:0)

使用命名空间mx_internal,并像这样添加radiobutton

 use namespace mx_internal;

 public function AddRadioButton(elxRdButton:ElxRadioButton):void
    {
     id_RdGroup.addInstance(elxRdButton);
    if (elxRdButton.selected)
    {
    id_RdGroup.selection = elxRdButton;
    }
    m_aRdButtons.addItem(elxRdButton);
    }

现在选择将完美运作:)