我正在制作一个游戏,用户将在游戏结束时查看他/她的高分和得分。这是播放器看到结果页面时的代码:
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();
}