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();
}