我使用flash as3創建菜單時出現問題。你們能幫助我應該怎麼做...?就像這樣:Flash錯誤#1009:無法訪問空對象引用....的屬性或方法?
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at DocumentClass/menuScreen()
at DocumentClass/mouseBack()
如何正確的代碼來解決代碼如下:
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.system.fscommand;
import flash.display.StageDisplayState;
public class DocumentClass extends MovieClip {
public var backbutton:BackButton = new BackButton();
public function DocumentClass() {
menuScreen();
stage.addEventListener(Event.ENTER_FRAME, masukGame);
}
public function masukGame(e:Event):void{
stage.displayState = StageDisplayState.FULL_SCREEN;
}
public function menuScreen():void{
game.menuscreen.mb.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick1);
game.menuscreen.pb.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick2);
game.menuscreen.mlb.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick3);
game.menuscreen.kb.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick4);
}
public function backMenu():void{
backbutton.buttonMode = true;
backbutton.addEventListener(MouseEvent.MOUSE_DOWN, mouseBack);
backbutton.x = 450;
backbutton.y = 400;
// Dan akhirnya letakan button ke stage;
addChild(backbutton);
backbutton.visible=true;
}
public function mouseClick1(event:MouseEvent):void {
game.gotoAndStop("MainGame");
backMenu();
}
public function mouseClick2(event:MouseEvent):void {
game.gotoAndStop("Petunjuk");
backMenu();
}
public function mouseClick3(event:MouseEvent):void {
game.gotoAndStop("Malaria");
backMenu();
}
public function mouseClick4(event:MouseEvent):void {
game.gotoAndStop("Keluar");
backMenu();
}
public function mouseBack(event:MouseEvent):void {
menuScreen();
}
}
}
這是我的文件,在這裏下載:https://www.dropbox.com/s/jo7bcwnlfj7qjnh/My%20Game.rar
請幫助我,感謝傢伙..
你能展示我必須做的代碼或解決方案嗎?因爲我是新的蜜蜂......對於Flash ......請謝謝...... –