Skip to main content
Inspiring
October 7, 2015
Answered

TextField Not Displaying

  • October 7, 2015
  • 1 reply
  • 297 views

var spec:TextField = new TextField();

spec.defaultTextFormat = new TextFormat('Arial', 18, 0xFF0000, true);

stage.addChild(spec);

spec.x = spec_men.x;

spec.y = spec_men.y;

spec.width = spec_men.width;

spec.height = spec_men.height;

spec.text = 'hello';

This code, for some reason, does not put the text field anywhere on the stage. All the objects referenced exist and a trace statement shows that it has text, but it is no where to be found.

I had a problem like this before where the text was behind my background image, but I checked and it's not.

What am I doing wrong?

This topic has been closed for replies.
Correct answer dmennenoh

Did you verify where it actually is? You could try something like:

var spec_men:Object = {x:0,y:0,width:100,height:30};

in order to force the loc and size.

Also, I'd remove stage from addChild

1 reply

dmennenohCorrect answer
Inspiring
October 7, 2015

Did you verify where it actually is? You could try something like:

var spec_men:Object = {x:0,y:0,width:100,height:30};

in order to force the loc and size.

Also, I'd remove stage from addChild

mcdermittAuthor
Inspiring
October 7, 2015

All right, it works!

Thanks!