Skip to main content
Participating Frequently
May 27, 2013
Answered

Text box disappears after flipping a movieclip?

  • May 27, 2013
  • 2 replies
  • 866 views

As title says, the textbox which was created in a function disappears after being flipped (scaleX = -1). Is there any way to fix it? The textbox contains the value of health, and it belongs to an Enemy unit. When the enemy unit turns to face another direction, the textbox disappears.

Here's my function.

private function draw():void

        {

            healthTxt = new TextField();

            healthTxt.defaultTextFormat = new TextFormat("Rockwell", 15, 0xFF0000, 1)

            healthTxt.height = 20;

            healthTxt.width = 20;

            healthTxt.x = -10;

            healthTxt.y = -28;

            healthTxt.text = health + "";

            addChild(healthTxt);

            ;

        }

Everything was instantiated properly. Any help would be appreciated. Thanks!

This topic has been closed for replies.
Correct answer Ned Murphy

Thanks for the quick reply Ned. I have embedded the font in Flash CS5. Does it work if I do it that way or must I do it the way which is specified under AS3?

EDIT: Sorry, I sort of fixed it by adding

healthTxt.embedFonts = true;.

However, when the unit turns now, the number flips together with it...


If the unit contains the textfield, then the textfield will turn with the unit.

2 replies

Ned Murphy
Legend
May 27, 2013

If you manipulate the orientation of the textfield, such as flipping it or even rotating it, you need to embed the font.  Otherwise the text will not display.

SpexeDAuthor
Participating Frequently
May 27, 2013

Hi Ned, thanks for the reply. I have already embedded the font (in this case, Rockwell bold) and it works when the unit gets hit by a bullet (i.e the hp decreases by 1). However, when I change the orientation the number still simply disappears. Any idea? Thanks!

Oh, if it helps, the code is in the enemy class.

Ned Murphy
Legend
May 27, 2013

I do not see anything that is embedding the font in the code you show.

Inspiring
May 27, 2013

how is the textfield tied to the enyemy? Is it a child of enemy?

SpexeDAuthor
Participating Frequently
May 27, 2013

Yep.