我正在构建一个简单的计算器但是当我单击包含数字的按钮时,它将不会显示在我推出的动态文本框中。我已经检查了我的实例名称,重新检查代码,他们都很好,我似乎得到了错误TypeError: Error #1009: Cannot access a property or method of a null object reference.
at game/frame1()
import flash.events.MouseEvent;
one_btn.addEventListener(MouseEvent.CLICK, displayText);
two_btn.addEventListener(MouseEvent.CLICK, displayText);
three_btn.addEventListener(MouseEvent.CLICK, displayText);
function displayText(event:MouseEvent):void {
trace(event.target.name);
if(event.target.name == "one_btn"){
txtAnswer.appendText("1");
}
if(event.target.name == "two_btn"){
txtAnswer.appendText("2");
}
if(event.target.name == "three_btn"){
txtAnswer.appendText("3");
}
}