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

TextField won't display if parent is a child?

Explorer ,
Feb 05, 2014 Feb 05, 2014

Hi!

I'm writing a new framework but I've encountered an odd bug. Whenever I add a class as a child to my main sprite, it doesn't display the class's TextField. Only if I add it as a child of the stage will it display.

Main.as (Highlighted as Java)

spirea = new World(this.stage);

                                spirea.addChild(new LoginForm(spirea));

LoginForm.as

public class LoginForm extends Sprite

          {

                    public var usernameField:TextField;

                    public var passwordField:TextField;

                    public function LoginForm(w:World)

                    {

                              usernameField = new TextField;

                              usernameField.x = 200;

                              usernameField.y = 50;

                              usernameField.width = 200;

                              usernameField.height = 35;

                              usernameField.border = true;

                              usernameField.borderColor = 0x000000;

                              usernameField.type = TextFieldType.INPUT;

                              addChild(usernameField);

                    }

          }

World is an extention of Sprite with a shaded bitmap added to it for decoration. It's a constant throughout the game, as in it doesn't disappear. The present code doesn't work. If I don't make it a child of spirea, it will work just fine. However, if I do w.addChild(usernameField); in LoginForm.as, it doesn't work. Neither does a combination of spirea.addChild(new LoginForm(spirea)); in Main.as and w.addChild(usernameField);

Is this just the nature of TextField or am I doing something very wrong?   

TOPICS
ActionScript
462
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 , Feb 05, 2014 Feb 05, 2014

Yes you must add spirea to the display list so its children can be seen.

Translate
LEGEND ,
Feb 05, 2014 Feb 05, 2014

Yes you must add spirea to the display list so its children can be seen.

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
Explorer ,
Feb 05, 2014 Feb 05, 2014

Ah I removed that line! Gah that should have been obvious..

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 ,
Feb 06, 2014 Feb 06, 2014
LATEST

We all look at the same code too long and just go blind, happens all the time . Good luck!

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