1
我正在製作一個遊戲,用戶在遊戲結束時將查看他/她的高分和得分。這是玩家看到結果頁面時的代碼:爲什麼我的動態文本字段有時會填充,有時不填?
function showresults():void
{
var so:SharedObject = SharedObject.getLocal("alltimeHighScore");
if (so.data.score == undefined || score > so.data.score)
{
endscreen_mc.scoreR_txt.text = String(score);
endscreen_mc.highscore_txt.text = String(score);
}
if (score < so.data.score)
{
endscreen_mc.scoreR_txt.text = String(score);
endscreen_mc.highscore_txt.text = String(so.data.score);
}
so.data.score = score;
so.flush();
}
它有時會填充,有時不填充。我有一個類似的代碼另一個層面,以及:
function showresultsA():void
{
var so:SharedObject = SharedObject.getLocal("alltimeHighScore");
if (so.data.scoreA == undefined || scoreA > so.data.scoreA)
{
endscreenA_mc.Ascore_txt.text = String(scoreA);
endscreenA_mc.highscoreA_txt.text = String(scoreA);
}
if (scoreA < so.data.scoreA)
{
endscreenA_mc.Ascore_txt.text = String(scoreA);
endscreenA_mc.highscoreA_txt.text = String(so.data.scoreA);
}
so.data.scoreA = scoreA;
so.flush();
}