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";
TextField. You assign aTextFormatobject to thedefaultTextFormatproperty of theTextFieldand also call thesetTextFormat(format)method of theTextFieldwhen changing fonts. Posting yourmc.createTextFieldmethod source would also help, as we can't really see what you do in there. As @Discipol answered, you'll also need to add any kind ofDisplayObjectto theDisplayListto make it visible, but if the red rectangle is drawn I assume you already added it. - Gioms.creatyeTextField? It's the standard MovieClip.createTextField method. - Paul MantaMovieClip. So in Actionscript 3 you don't create aTextFieldlike that. The correct way to create aTextFieldin AS3 is as follows:var tf:TextField = new TextField();Then you add it as a child to a parentDisplayObjectContainerand set aTextFormatif needed. - Gio