Skip to main content
Participant
May 18, 2014
Question

quizze with radiobutton (4 questions) -- don´t work correctly

  • May 18, 2014
  • 1 reply
  • 328 views

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."

}

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
May 18, 2014

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

Participant
May 18, 2014

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."

}

Participant
May 18, 2014