我实际上是在尝试检查游戏的分数是否为高分。然后如果是,分数将被添加到排行榜中。但是我收到了这个错误:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlashGame_fla::MainTimeline/checkBananaHS()
在我的游戏中,在那个特定的帧中,这是链接到 checkBananaHS() 的代码:
function rpslsWon():void
{
gameOverBananaMC.visible = true;
bananaWinLose.visible = true;
bananaWinLose.text = "Kampai " + cPlayerData.pName + "! You are totally bananas!! \nYour Score: " + pBananaScore;
toMenuBtn.visible = true;
rollAgainBtn.visible = true;
toMenuBtn.addEventListener(MouseEvent.CLICK, Click_backtoMain);
rollAgainBtn.addEventListener(MouseEvent.CLICK, backtoBanana);
saveItBtn.addEventListener(MouseEvent.CLICK, checkBananaHS);
cPlayerData.pBananaScore = pBananaScore;
saveData();
tracePlayerData();
}
这是高分帧中的一段代码:
var rpslsHighScore:int;
var rpslsHSName:String;
rpslsHighScore = 0;
rpslsHSName = "";
//rpslsHighScore = 0;
bananaWinnerDisplay.text = " ";
bananaScoreDisplay.text = "0";
function checkBananaHS(event:MouseEvent):void
{
if ((cPlayerData.pBananaScore > rpslsHighScore ||
rpslsHighScore == 0) && cPlayerData.pBananaScore > 0)
{
trace("There's a new high score for Banana");
rpslsHighScore = cPlayerData.pBananaScore;
rpslsHSName = cPlayerData.pName;
bananaScoreDisplay.text = "" + rpslsHighScore;
bananaWinnerDisplay.text = rpslsHSName;
saveData();
}
}
我只是无法修复错误。谁能帮我吗?非常感谢!