执行操作后,Actionscript 在屏幕上显示文本

Actionscript display text on screen once an action is performed

所以我需要在执行操作后显示文本,但即使我尝试使用动态文本和标签来显示,但由于错误我未能完成我的编程:

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
}

我首先看到的是您正在使用 == 设置一个值。设置值时需要使用=。所以像这样:

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

或者您可以像这样使用 counter++

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