質問

I created a MovieClip symbol named HS_num from a dynamic text box, that currently contains the number 0. I am trying to load this to the stage when a new high score is acheived, and set the text of the object to that highscore, numScore.

This is my code for the high score:

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

Could someone explain how to change the text of this MovieClip? Thanks!

役に立ちましたか?

解決

Your text field should be an input text field. Let's say its instance name is hsNum. You put it on stage like any display object. Now you can change its text like this: hsNum.text = "thistextrighthere" or hsNum.text = " " or hsNum.text = thisstring, where you've already defined thisstring.

So, the relevant bit of your code might be:

 hsNum.text = String(new_hs_num);

Remember to 'embed' the appropriate characters for your input text field.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top