我正在制作一个简单的Flash游戏,这个用户可以选择要去哪个部分的菜单。当我点击口头按钮(verbal_btn)去语言部分。我得到了类型错误
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at elearning2_fla::MainTimeline/playSmall()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at elearning2_fla::MainTimeline/verbalSmall()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at elearning2_fla::MainTimeline/frame205()
我将所有实例都命名为正确的框架,其中代码是没有实例或按钮的副本。
stop();
physical_btn.buttonMode = true
physical_btn.addEventListener(MouseEvent.CLICK, physicalGame);
function physicalGame(event:MouseEvent): void {
gotoAndPlay(455);
}
physical_btn.addEventListener(MouseEvent.MOUSE_OVER, physicalBig);
function physicalBig(event:MouseEvent): void {
physical_btn.scaleX=1.5;
physical_btn.scaleY=1.5;
}
physical_btn.addEventListener(MouseEvent.MOUSE_OUT, physicalSmall);
function physicalSmall(event:MouseEvent): void {
physical_btn.scaleX=1;
physical_btn.scaleY=1;
}
cyber_btn.buttonMode = true
cyber_btn.addEventListener(MouseEvent.CLICK, cyberGame);
function cyberGame(event:MouseEvent): void {
gotoAndPlay(720);
}
cyber_btn.addEventListener(MouseEvent.MOUSE_OVER, cyberBig);
function cyberBig(event:MouseEvent): void {
cyber_btn.scaleX=1.5;
cyber_btn.scaleY=1.5;
}
cyber_btn.addEventListener(MouseEvent.MOUSE_OUT, cyberSmall);
function cyberSmall(event:MouseEvent): void {
cyber_btn.scaleX=1;
cyber_btn.scaleY=1;
}
verbal_btn.buttonMode = true
verbal_btn.addEventListener(MouseEvent.CLICK, verbalGame);
function verbalGame(event:MouseEvent): void {
gotoAndPlay(190);
}
verbal_btn.addEventListener(MouseEvent.MOUSE_OVER, verbalBig);
function verbalBig(event:MouseEvent): void {
verbal_btn.scaleX=1.5;
verbal_btn.scaleY=1.5;
}
verbal_btn.addEventListener(MouseEvent.MOUSE_OUT, verbalSmall);
function verbalSmall(event:MouseEvent): void {
verbal_btn.scaleX=1;
verbal_btn.scaleY=1;
}
这是我在口头部分输入框架时的代码。唯一可行的按钮是信息按钮(info_btn)。其余的不管你点击它们什么都不做。
var mySound5:UHOH = new UHOH();
var mySound4:DING = new DING();
info_mc.addEventListener(MouseEvent.CLICK, verbalInfo);
function verbalInfo(event:MouseEvent): void {
gotoAndPlay(452);
}
info_mc.addEventListener(MouseEvent.MOUSE_OVER, infoBig);
function infoBig(event:MouseEvent): void {
info_mc.scaleX=1.2;
info_mc.scaleY=1.2;
}
info_mc.addEventListener(MouseEvent.MOUSE_OUT, infoSmall);
function infoSmall(event:MouseEvent): void {
info_mc.scaleX=1;
info_mc.scaleY=1;
}
menu_btn.addEventListener(MouseEvent.CLICK, verbalMenu);
function verbalMenu(event:MouseEvent): void {
gotoAndPlay(180);
}
menu_btn.addEventListener(MouseEvent.MOUSE_OVER, bigMenu);
function bigMenu(event:MouseEvent): void {
menu_btn.scaleX=1.1;
menu_btn.scaleY=1.1;
}
menu_btn.addEventListener(MouseEvent.MOUSE_OUT, smallMenu);
function smallMenu(event:MouseEvent): void {
menu_btn.scaleX=1;
menu_btn.scaleY=1;
}
nasty_btn.addEventListener(MouseEvent.CLICK, verbalNasty);
function verbalNasty(event:MouseEvent): void {
mySound4.play();
gotoAndPlay(206);
}
nasty_btn.addEventListener(MouseEvent.MOUSE_OVER, nastyBig);
function nastyBig(event:MouseEvent): void {
nasty_btn.scaleX=1.2;
nasty_btn.scaleY=1.2;
}
nasty_btn.addEventListener(MouseEvent.MOUSE_OUT, nastySmall);
function nastySmall(event:MouseEvent): void {
nasty_btn.scaleX=1.1;
nasty_btn.scaleY=1.1;
}
pretty_btn.addEventListener(MouseEvent.CLICK, verbalPretty);
function verbalPretty(event:MouseEvent): void {
mySound5.play();
}
pretty_btn.addEventListener(MouseEvent.MOUSE_OVER, prettyBig);
function prettyBig(event:MouseEvent): void {
pretty_btn.scaleX=1.2;
pretty_btn.scaleY=1.2;
}
pretty_btn.addEventListener(MouseEvent.MOUSE_OUT, prettySmall);
function prettySmall(event:MouseEvent): void {
pretty_btn.scaleX=1.1;
pretty_btn.scaleY=1.1;
}
nice_btn.addEventListener(MouseEvent.CLICK, verbalNice);
function verbalNice(event:MouseEvent): void {
mySound5.play();
}
nice_btn.addEventListener(MouseEvent.MOUSE_OVER, niceBig);
function niceBig(event:MouseEvent): void {
nice_btn.scaleX=1.2;
nice_btn.scaleY=1.2;
}
nice_btn.addEventListener(MouseEvent.MOUSE_OUT, niceSmall);
function niceSmall(event:MouseEvent): void {
nice_btn.scaleX=1.1;
nice_btn.scaleY=1.1;
}
trace(nice_btn);
stop();
谢谢