Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Text box disappears after flipping a movieclip?

New Here ,
May 26, 2013 May 26, 2013

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!

TOPICS
ActionScript
804
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 27, 2013 May 27, 2013

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

Translate
Guru ,
May 26, 2013 May 26, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2013 May 27, 2013

Yep.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 27, 2013 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2013 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 27, 2013 May 27, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 27, 2013 May 27, 2013

Though I have not reviewed the accuracy of the information, here is a link that has a tutorial about embedding the font for dynamically created textfields:

http://forums.epicgames.com/threads/885514-AS2-AS3-Embedding-Fonts-to-be-Used-by-a-Dynamically-Creat...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2013 May 27, 2013

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 27, 2013 May 27, 2013
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines