Does changing the dyanmic text box in MovieClip added to step AS3 not work?

When I change the text value of a dynamic text field, the text field simply gets empty without showing the new value.

I have a MovieClip called "game_board" that is added to the scene using AS3. (for starters, the stage is empty.)

I have another MovieClip called "stage_2" that is added as a child of the "game_board" dynamically using AS3.

"stage_2" contains a prebuilt circuit board with various dynamic text fields on it. All have instance names. For example, "text_1". The initial 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 successfully shows the new value, however the text field on the scene showing "0" now shows absolutely nothing, it just disappears. I tried to run addChild if for some reason it was moved to the bottom layer, but this did not work. Even when there is only this text field on the stage, it is still just empty.

What am I doing wrong?

+4
source share
1 answer

try the following:

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

because flash cs5 uses embedFonts by default, so if you haven't installed a font in your library and then attach it to your document, flash cs5 will only embed fonts that are only in your text input, you can run a test if you change the value of text_1 from 0 to te and delete embedFonts , you will only get tet without s to use embedFonts in all your text, see this: Embedding fonts in AS3 - the dynamic text field disappears

+5
source

Source: https://habr.com/ru/post/1412184/


All Articles