PDA

View Full Version : [AS3] Radio Button Question


baldtrainer
03-03-2009, 09:35 PM
I'm creating a quiz that includes multiple answers. I'm trying to use the radio buttons; however, it will only allow me to choose 1 answer at a time. Anyone know if I can set this up so I can choose multiple answers??

Here's my code...


import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
import fl.controls.Button;

var rbQuizGroup:RadioButtonGroup = new RadioButtonGroup("Multiple Choice");

rb1.group = rbQuizGroup;
rb2.group = rbQuizGroup;
rb3.group = rbQuizGroup;
rb4.group = rbQuizGroup;
rb5.group = rbQuizGroup;
rb6.group = rbQuizGroup;

rb1.label = "Characteristics";
rb2.label = "Cost";
rb3.label = "Convenience";
rb4.label = "Comparison";
rb5.label = "Compatiblility";
rb6.label = "Customer Care";

rb1.value = 1;
rb2.value = 0;
rb3.value = 1;
rb4.value = 1;
rb5.value = 0;
rb6.value = 0;

mc_submit.addEventListener(MouseEvent.CLICK, checkAnswer2);
function checkAnswer2(event:MouseEvent):void
{
if(Number(rbQuizGroup.selectedData == 1))
{
resultBox.text = "Hello World";
}
}

secondToLast
03-03-2009, 09:43 PM
its an interesting idea.. i thought the point of a radioButton group is that it allows you to choose only one. can you use checkboxes instead?

i suppose of you made each radio button seperate (its own group or no group) you could select each as you liked. but i think if they are in one group you are restricted to one choice... thats the point of grouping them... no?