Skip to main content
nbautista
Known Participant
May 22, 2009
Question

I need to reset, clear or deselect a group of radio buttons

  • May 22, 2009
  • 1 reply
  • 6589 views

I haven't been able to find the answer to this: I have a quiz-like animation that uses a group of radio buttons, I need the group to reset, clear or deselect the previous selection after submitting the answer on each question, is that possible?

Here is the code:

stop();

var messageBox:TextField = new TextField();

messageBox.text = "";

addChild(messageBox);

messageBox.textColor = 0xFF0000;

messageBox.width = 200;

messageBox.height =100;

messageBox.x = 450;

messageBox.y = 340;

var userAnswer:int;

var rbg:Object = rbA.group;

var finalScore:int;

btnCheck.addEventListener(MouseEvent.CLICK, nextBtn);

function nextBtn(evt:MouseEvent):void {

userAnswer = int(rbg.selectedData);

            if(userAnswer == 0) {messageBox.text = "PLEASE SELECT AN OPTION";

}else{

finalScore = finalScore + userAnswer;

messageBox.text = "";

nextFrame();

}

}

btnFinish.addEventListener(MouseEvent.CLICK, finishBtn);

function finishBtn (evt:MouseEvent):void {

userAnswer = int(rbg.selectedData);

if(userAnswer == 0) {messageBox.text = "PLEASE SELECT AN OPTION";

}else{

finalScore = finalScore + userAnswer;

if (finalScore > 13){ gotoAndStop(8);

}else if (finalScore > 9){ gotoAndStop(7);

}else if (finalScore > 4){ gotoAndStop(6);

}else {}

}

}

startOver.addEventListener(MouseEvent.CLICK, reStart);

function reStart(evt:MouseEvent):void {

gotoAndStop(1);

finalScore = 0;

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 22, 2009

yes, radiobuttons have a selected property that you can assign to false to clear the checkmark.

nbautista
nbautistaAuthor
Known Participant
May 22, 2009

Thanks, can you tell me what's the sintax and where in the code do I put it?