0

So I need to display a text once an action is performed but even though I tried to do so by using dynamic text and labels, I didn't manage to finish my programming due to errors:

var group:RadioButtonGroup= new RadioButtonGroup ("Question1");
var group2:RadioButtonGroup= new RadioButtonGroup ("Question2");
var group3:RadioButtonGroup= new RadioButtonGroup ("Question3");
var group4:RadioButtonGroup= new RadioButtonGroup ("Question4");
var group5:RadioButtonGroup= new RadioButtonGroup ("Question5");
var counterT:int;
var counterF:int;

submit.buttonMode=true;
counterT=0;
counterF=0;

t1.group = group;
f1.group = group;

t2.group=group2;
f2.group=group2;

t3.group=group3;
f3.group=group3;

t4.group=group4;
f4.group=group4;

t5.group=group5;
f5.group=group5;

submit.label="Submit";
submit.addEventListener(MouseEvent.CLICK,submitanswer); 

function submitanswer (event:MouseEvent): void {
    if (group.selection == t1)  {
        counterT==counterT+1
    }
    else 
    if (group.selection==f1) {
        counterF==counterF+1;
    }
}
if (group2.selection ==t2) {
    counterT==counterT+1
}
else
if (group2.selection==f2) {
    counterF==counterF+1
}
if (group3.selection ==t3) {
    counterT==counterT+1
}
else
if (group3.selection==f3) {
    counterF==counterF+1
}
if (group4.selection ==t4) {
    counterT==counterT+1
}       
else
if (group4.selection==f4) {
    counterF==counterF+1
}
if (group5.selection ==t5) {
    counterT==counterT+1
}       
else
if (group5.selection==f5) {
    counterF==counterF+1
}
Brian
  • 3,850
  • 3
  • 21
  • 37

1 Answers1

1

The first thing I see is that you are using the == to set a value. You need to use = when setting values. So like this:

if (x == y) {
    counter = counter + 1;
}

or you can just use counter++ like this

if (x == y) {
    counter++;
}
Neal Davis
  • 2,010
  • 2
  • 12
  • 25
  • I noticed that today however right now I am trying to return the values and i get the error 1051 Return value must be undefined. thus I can't print **if (group5.selection==f5) { counterF=counterF+1 } return counterT; return counterF; } } submit.addEventListener (MouseEvent.CLICK, submitanswer) txtField.text = " You've got " + counterT + " correct answers and " + counterF + " wrong answers";** – Panagiota Zanettou May 13 '16 at 10:28
  • This is a different question than your original post, I think. If your first question is solved, mark it as correct. Each post is to essentially be one question and one answer so that others with the same problem can come find the solution. If you are having a new problem, first see if a similar question has been asked. If not, post a new question. – Neal Davis May 13 '16 at 21:06
  • well the text isn't printed when I click the submit button yet no matter what actions i try it's either printed before or not printed at all – Panagiota Zanettou May 14 '16 at 08:01
  • Ok but what I'm saying is you don't have any code here that would cause anything to print, so this question can't be about printing. If you have a printing question, and there isn't a previous post that helps with your problem, ask a new question or clarify this one. You should not just keep updating a question with what ever your new problem is. – Neal Davis May 14 '16 at 13:22
  • If you will post your updated code by editing your original post, I will take a look. Also please include where your code is written (in an .as file, or in frame 1 of the timeline, etc.) Trying to read code in a comment is too hard. – Neal Davis May 15 '16 at 12:20
  • Thanks but some friends helped me to get out of it :) thanks for all your help as well! – Panagiota Zanettou May 15 '16 at 17:52