Changing dyanmic text field in MovieClip added to stage by AS3 is not working?

BumbleShrimp picture BumbleShrimp · May 12, 2012 · Viewed 8.8k times · Source

When I change the text value of a dynamic text field, the text field is just going blank, not showing the new value.

I have a MovieClip titled "game_board" that is added to the stage dyanmically by AS3. (stage is blank to begin with.)

I have another MovieClip titled "stage_2" that is added as a child to "game_board" dynamically by AS3.

"stage_2" contains a prebuilt board with different dynamic text fields on it. They all have instance names. For example "text_1". The original value of this.game_board.stage_2.text_1.text is 0.

When I do this:

this.game_board.stage_2.text_1.text = "test";

trace(this.game_board.stage_2.text_1.text); //succesfully shows new value, "test"

The trace succesfully shows the new value, however the text field on the stage, which was showing "0", now shows absolutely nothing, it just disappears. I tried running addChild in case it was being moved to the bottom layer for some reason, but that didn't work. Even when the stage only contains that text field, it still just goes blank.

What am I doing wrong?

Answer

mgraph picture mgraph · May 12, 2012

try this:

this.game_board.stage_2.text_1.embedFonts = false;
this.game_board.stage_2.text_1.text = "test";

that happend because flash cs5 use embedFonts by default, so if you didn't set a font in your library then attach it to your document, flash cs5 will only embed Fonts that are in your Text input only, you can do test if you change the value of text_1 from 0 to te and remove embedFonts you will only get tet without s, to use embedFonts in all your text see this: Embedding Fonts in AS3 - Dynamic Text Field disappears