我一直收到以下错误:
TypeError:错误#1010:术语未定义且没有属性。在 FinalGame_fla :: MainTimeline /脉冲() [FinalGame_fla.MainTimeline ::帧1:183]
我已多次检查代码,似乎无法找出错误的原因,因为高分表仍会显示正确的条目。
下面是显示已定义变量的代码以及导致问题的代码本身。
定义变量&阵列
var playerName:String="Anonymous";
var allScores:Array = new Array();
var nameBoxes:Array = new Array(mcScoreboard.player1, mcScoreboard.player2, mcScoreboard.player3, mcScoreboard.player4, mcScoreboard.player5);
var scoreBoxes:Array = new Array(mcScoreboard.score1, mcScoreboard.score2, mcScoreboard.score3, mcScoreboard.score4, mcScoreboard.score5);
var sr:SharedObject=SharedObject.getLocal("previousResults");
if (sr.data.allScores!=undefined)
{
allScores = sr.data.allScores;
}
显示高分的功能
if (livesLeft==0)
{
stopGame();
mcScoreboard.visible=true;
var playerScore:Object = new Object();
playerScore["name"] = playerName;
playerScore["score"] = totalScore;
allScores.push(playerScore);
sr.data.allScores = allScores;
sr.flush();
allScores.sortOn("score", Array.DESCENDING|Array.NUMERIC);
for (var i=0;i<allScores.length;i++)
{
var obj:Object = allScores[i];
*nameBoxes[i].text = obj["name"];*
scoreBoxes[i].text = obj["score"];
}
}
Flash表示显示倒数第二行是导致问题的原因。但是所有的变量和数组都被正确地声明了,所以我不明白我哪里出错了。