取消选择as3中的单选按钮

时间:2011-11-01 15:27:21

标签: flash actionscript-3

我想在转到下一帧时取消选择单选按钮

confirm_btn.addEventListener(MouseEvent.CLICK,confirm)
    function confirm( event:MouseEvent):void{
        if(radioGroup1.selection.label== "null")
        {return;}
        else
        {
            answers.push(radioGroup1.selection.label)
           //unselect all selected radio buttons                

        }

    frame= frame+1
    gotoAndPlay(frame); 
}

我尝试了radioGroup1.selected = false和null但没有工作

1 个答案:

答案 0 :(得分:2)

抱歉,我的不好,你不能将RadioButton selected属性设置为false,你只能将它设置为true,这意味着取消选择该按钮的唯一方法是选择另一个,实际上将另一个按钮selected属性设置为true !

radioGroup1.addEventListener(Event.CHANGE, changeHandler);

function changeHandler(event:Event):void 
{
  answers.push(radioGroup1.selection.label);

  //assuming that you have a defaultButton...
  defaultButton.selected = true;

}