Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
May 18, 2014 May 18, 2014

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

}

TOPICS
ActionScript
288
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2014 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2014 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."

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2014 May 18, 2014
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2014 May 18, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2014 May 18, 2014

Thanks very much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2014 May 18, 2014
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines