我正在尝试创建一个动态文本字段,单击该字段时会填充一个数字。如果文本字段中显示 2,并且用户单击它,则应显示 1,如果显示 1,并且用户单击,则应再次显示 1。但是我的代码似乎有问题。相反,当显示 2 并单击它时,会显示 1,但如果再次单击它,则不会显示 2。我该如何解决这个问题?
import flash.events.MouseEvent;
var onoff:Number;
onoff = 2
options_mc.onoff_txt.text = String(onoff);
options_mc.onoff_txt.addEventListener(MouseEvent.CLICK, tick);
function tick(event:MouseEvent)
{
if(onoff = 1)
{
onoff = 2
options_mc.onoff_txt.text = String(onoff);
options_mc.onoff_txt.addEventListener(MouseEvent.CLICK, tick);
}
else(onoff = 2)
{
onoff = 1
options_mc.onoff_txt.text = String(onoff);
options_mc.onoff_txt.addEventListener(MouseEvent.CLICK, tick);
}
}