我知道这个问题被发布了一百万次,我阅读了所有的答案,但我仍然无法弄清楚我的游戏中的问题出在哪里,我遇到了这个错误
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at habitadnew_fla::MainTimeline/frame2()
at flash.display::MovieClip/gotoAndStop()
at habitadnew_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame_11()
我一次又一次地构建我的电影剪辑和我的按钮,但我仍然收到这个错误。你能帮我么。我是闪光灯新手。如果有人想查看我的代码,我将我的游戏上传到http://snk.to/f-ctpm6nj1。
谢谢
框架1
stop();
tree.buttonMode=true;
bird.buttonMode=true;
worm.buttonMode=true;
snail.buttonMode=true;
caterpillar.buttonMode=true;
fox.buttonMode=true;
owl.buttonMode=true;
hedgehog.buttonMode=true;
treeA.visible=false;
owlA.visible=false;
hedgehogA.visible=false;
wormA.visible=false;
birdA.visible=false;
snailA.visible=false;
caterpillarA.visible=false;
foxA.visible=false;
function playSound(SoundName:Class):void{
var sound = new SoundName();
var channel:SoundChannel = sound.play();
}
owl.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
owl.alpha = 0
owlA.visible=true;
playSound(sosto);
}
tree.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler1);
function fl_MouseClickHandler1(event:MouseEvent):void
{
tree.alpha = 0
treeA.visible=true;
playSound(sosto);
}
snail.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler2);
function fl_MouseClickHandler2(event:MouseEvent):void
{
snail.alpha = 0
snailA.visible=true;
playSound(sosto);
}
bird.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler3);
function fl_MouseClickHandler3(event:MouseEvent):void
{
bird.alpha = 0
birdA.visible=true;
playSound(sosto);
}
worm.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler4);
function fl_MouseClickHandler4(event:MouseEvent):void
{
worm.alpha = 0
wormA.visible=true;
playSound(sosto);
}
caterpillar.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler5);
function fl_MouseClickHandler5(event:MouseEvent):void
{
caterpillar.alpha = 0
caterpillarA.visible=true;
playSound(sosto);
}
hedgehog.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler6);
function fl_MouseClickHandler6(event:MouseEvent):void
{
hedgehog.alpha = 0
hedgehogA.visible=true;
playSound(sosto);
}
fox.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler7);
function fl_MouseClickHandler7(event:MouseEvent):void
{
fox.alpha = 0
foxA.visible=true;
playSound(sosto);
}
text_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_11);
function fl_ClickToGoToAndStopAtFrame_11(event:MouseEvent):void
{
gotoAndStop(2);
}
chain_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_20);
function fl_ClickToGoToAndStopAtFrame_20(event:MouseEvent):void
{
gotoAndStop("sort1");
}
who_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_22);
function fl_ClickToGoToAndStopAtFrame_22(event:MouseEvent):void
{
gotoAndStop("wholabel");
}
search_btn.addEventListener(MouseEvent.CLICK, searchbutton);
function searchbutton(event:MouseEvent):void
{
trace("mouse click");
}
第 2 帧
text1_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);
function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void
{
gotoAndStop("hedgehoclabel");
}
text2_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_13);
function fl_ClickToGoToAndStopAtFrame_13(event:MouseEvent):void
{
gotoAndStop("owllabel");
}
text3_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_14);
function fl_ClickToGoToAndStopAtFrame_14(event:MouseEvent):void
{
gotoAndStop("treelabel");
}
text4_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_15);
function fl_ClickToGoToAndStopAtFrame_15(event:MouseEvent):void
{
gotoAndStop("caterpillarlabel");
}
text5_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_16);
function fl_ClickToGoToAndStopAtFrame_16(event:MouseEvent):void
{
gotoAndStop("wormlabel");
}
text6_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_17);
function fl_ClickToGoToAndStopAtFrame_17(event:MouseEvent):void
{
gotoAndStop("snaillabel");
}
text7_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_18);
function fl_ClickToGoToAndStopAtFrame_18(event:MouseEvent):void
{
gotoAndStop("birdlabel");
}
text8_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_19);
function fl_ClickToGoToAndStopAtFrame_19(event:MouseEvent):void
{
gotoAndStop("foxlabel");
}
search_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_101);
function fl_ClickToGoToAndStopAtFrame_101(event:MouseEvent):void
{
gotoAndStop(1);
}
text_btn.addEventListener(MouseEvent.CLICK, textnullbutton);
function textnullbutton(event:MouseEvent):void
{
trace ("mouse click");
}
chain_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_200);
function fl_ClickToGoToAndStopAtFrame_200(event:MouseEvent):void
{
gotoAndStop("sort1");
}
who_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_202);
function fl_ClickToGoToAndStopAtFrame_202(event:MouseEvent):void
{
gotoAndStop("wholabel");
}
第 3 帧
birdA1.buttonMode=true;
wormA1.buttonMode=true;
snailA1.buttonMode=true;
foxA1.buttonMode=true;
search_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_421);
function fl_ClickToGoToAndStopAtFrame_421(event:MouseEvent):void
{
gotoAndStop(1);
}
text_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_411);
function fl_ClickToGoToAndStopAtFrame_411(event:MouseEvent):void
{
gotoAndStop(2);
}
chain_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_410);
function fl_ClickToGoToAndStopAtFrame_410(event:MouseEvent):void
{
gotoAndStop("sort1");
}
who_btn.addEventListener(MouseEvent.CLICK, whonullbutton);
function whonullbutton(event:MouseEvent):void
{
trace ("mouce click");
}
wormA1.addEventListener(MouseEvent.MOUSE_DOWN, Dragworm);
function Dragworm(event:MouseEvent):void
{
wormA1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, Dropworm);
function Dropworm(event:MouseEvent):void
{
if (wormA1.x>455 &&wormA1.x<565 &&wormA1.y>430 &&wormA1.y<530) {
wormA1.stopDrag();
}
else
{
wormA1.stopDrag();
wormA1.x=753;
wormA1.y=185;
}
}
snailA1.addEventListener(MouseEvent.MOUSE_DOWN, Dragsnail);
function Dragsnail(event:MouseEvent):void
{
snailA1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, Dropsnail);
function Dropsnail(event:MouseEvent):void
{
if (snailA1.x>250 &&snailA1.x<360 &&snailA1.y>430 &&snailA1.y<530) {
snailA1.stopDrag();
}
else
{
snailA1.stopDrag();
snailA1.x=755;
snailA1.y=298;
}
}
birdA1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_6);
function fl_ClickToDrag_6(event:MouseEvent):void
{
birdA1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_6);
function fl_ReleaseToDrop_6(event:MouseEvent):void
{
if (birdA1.x>155 &&birdA1.x<260 &&birdA1.y>250 &&birdA1.y<355) {
birdA1.stopDrag();
}
else
{
birdA1.stopDrag();
birdA1.x=758;
birdA1.y=405;
}
}
foxA1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_7);
function fl_ClickToDrag_7(event:MouseEvent):void
{
foxA1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_7);
function fl_ReleaseToDrop_7(event:MouseEvent):void
{
if (foxA1.x>550 &&foxA1.x<660 &&foxA1.y>250 &&foxA1.y<350) {
foxA1.stopDrag();
}
else
{
foxA1.stopDrag();
foxA1.x=753;
foxA1.y=519;
}
}