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

与世无争的帅哥 提交于 2019-12-22 08:29:45

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/10567053/changing-dyanmic-text-field-in-movieclip-added-to-stage-by-as3-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!