Copy link to clipboard
Copied
Hi.
I create a quizze with radiobutton but
If the user clicks the option rb8. label in question 4 and click any option for questions 1,2,3 ... always emerges CORRECT.
ie, only the radioGroup4 works.
stop();
import fl.controls.RadioButtonGroup;
var radioGroup1:RadioButtonGroup = new RadioButtonGroup("Question1");
var radioGroup2:RadioButtonGroup = new RadioButtonGroup("Question2");
var radioGroup3:RadioButtonGroup = new RadioButtonGroup("Question3");
var radioGroup4:RadioButtonGroup = new RadioButtonGroup("Question4");
rb1.group=radioGroup1;
rb2.group=radioGroup1;
rb3.group=radioGroup2;
rb4.group=radioGroup2;
rb5.group=radioGroup3;
rb6.group=radioGroup3;
rb7.group=radioGroup4;
rb8.group=radioGroup4;
rb1.label="";
rb2.label="a";
rb3.label="b";
rb4.label="";
rb5.label="";
rb6.label="c";
rb7.label="";
rb8.label="d";
submit_btn.addEventListener(MouseEvent.CLICK, submitClick);
function submitClick(event:MouseEvent):void{
if((radioGroup1.selection==null)||(radioGroup2.selection==null)||(radioGroup3.selection==null)||(radioGroup4.selection==null)){
return;
}
if(radioGroup1.selection.label=="a", radioGroup2.selection.label=="b", radioGroup3.selection.label=="c", radioGroup4.selection.label=="d"){
status_txt.text="Correto... Parabéns.";
}else{
status_txt.text="Incorreto... Tente novamente."
}
Copy link to clipboard
Copied
The following line is not written properly whatever it is trying to accomplish - commas are not used for logical comparisons. It is likely only considering the last entry as a result though I would have exected an error. What is the intention for it?
if(radioGroup1.selection.label=="a", radioGroup2.selection.label=="b", radioGroup3.selection.label=="c", radioGroup4.selection.label=="d"){
If the they need to be correct then use && between each
If only one needs to be correct then use || between each
Copy link to clipboard
Copied
Thanks for reply.
I try but now
if the user clicks any option of question 1, 2 , 3 and 4... always emerges «Correto... Parabéns».
you can help me, please
stop();
import fl.controls.RadioButtonGroup;
var radioGroup1:RadioButtonGroup = new RadioButtonGroup("Question1");
var radioGroup2:RadioButtonGroup = new RadioButtonGroup("Question2");
var radioGroup3:RadioButtonGroup = new RadioButtonGroup("Question3");
var radioGroup4:RadioButtonGroup = new RadioButtonGroup("Question4");
rb1.group=radioGroup1;
rb2.group=radioGroup1;
rb3.group=radioGroup2;
rb4.group=radioGroup2;
rb5.group=radioGroup3;
rb6.group=radioGroup3;
rb7.group=radioGroup4;
rb8.group=radioGroup4;
rb1.label="";
rb2.label="v";
rb3.label="v";
rb4.label="";
rb5.label="";
rb6.label="v";
rb7.label="";
rb8.label="v";
submit_btn.addEventListener(MouseEvent.CLICK, submitClick);
function submitClick(event:MouseEvent):void{
if((radioGroup1.selection==null)||(radioGroup2.selection==null)||(radioGroup3.selection==null)||(radioGroup4.selection==null)){
return;
}
if((radioGroup1.selection.label=="v") || (radioGroup2.selection.label=="v") || (radioGroup3.selection.label=="v") || (radioGroup4.selection.label=="v")){
status_txt.text="Correto... Parabéns.";
}else{
status_txt.text="Incorreto... Tente novamente."
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
If you explain what you are trying to get the code to do I can help, but I suspect I already gave you the answer you need and you missed seeing it.
If they all need to be correct then use && between each
If only one needs to be correct then use || between each
Copy link to clipboard
Copied
Thanks very much.
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now