Paul Manta
Paul Manta

Reputation: 31577

Cannot get text in TextField to display

I'm trying to create a TextField dynamically in ActionScript 3. The code below draws the text box itself (which in this case is just a red rectangle), but the string "Add text here" is not displayed. What can I do to fix this problem?

var d:Number = mc.getNextHighestDepth();

var x:Number = (screenWidth - boxWidth) / 2;
var y:Number = (screenHeight - boxHeight) / 2;

var w:Number = boxWidth;
var h:Number = boxHeight;

notification = mc.createTextField("Text", d, x, y, w, h);
notification.background = true;
notification.backgroundColor = 0xFF0000;
notification.selectable = false;
notification.wordWrap = true;
notification.text = "Add text here";

Upvotes: 0

Views: 111

Answers (1)

Discipol
Discipol

Reputation: 3157

you need to do addChild( notification ) so that the textField is added to the display list.

Upvotes: 1

Related Questions