我有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)"/>
答案 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);
}
现在选择将完美运作:)