actionscript-3flashtextdisplaydynamic-text

Actionscript display text on screen once an action is performed


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
}

Solution

  • 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++;
    }