我从动态文本框中创建了一个名为HS_num
的MovieClip符号,该符号当前包含数字0
。我正在尝试将此加载到舞台上,以实现新的高分,并将对象的文本设置为该高分,numScore
。
这是我的高分代码:
try {
if (so.data.highScore < numScore) { //checking current score against saved score
isHighScore = true;
so.data.highScore = numScore;
trace("new highscore");
//pull up the splash screen:
var new_hs_splash = new new_HS(); //this is working fine,
new_hs_splash.x = 240; //it is a label that says "New High Score"
new_hs_splash.y = 570;
var new_hs_num = new highScoreNum();
new_hs_num.x = 360;
new_hs_num.y = 600;
new_hs_num.text = numScore.toString(); //this is what isn't working
//add it:
addChild(new_hs_splash);
addChild(new_hs_num);
}
else
trace("not a highscore");
}
catch (e: * ) { //catches the highscore never having been initialized
so.data.highScore = numScore;
trace("set first highscore");
}
有人可以解释如何更改此MovieClip的文字吗?谢谢!
答案 0 :(得分:0)
您的文本字段应为输入文本字段。假设它的实例名称是hsNum。你把它放在舞台上就像任何显示对象一样。现在您可以像这样更改其文本:
hsNum.text = "thistextrighthere"
或hsNum.text = " "
或hsNum.text = thisstring
,您已经定义了此字符串。
因此,代码的相关位可能是:
hsNum.text = String(new_hs_num);
请记住为您的输入文字字段“嵌入”相应的字符。