# Dynamically adding TextField to MovieClip

**URL:** https://forum.kirupa.com/t/dynamically-adding-textfield-to-movieclip/248657
**Category:** flash
**Created:** [January 10, 2008, 2:29pm UTC](https://forum.kirupa.com/t/dynamically-adding-textfield-to-movieclip/248657 "2008-01-10T14:29:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![psych](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/psych/32/2839_2.png) [@psych](https://forum.kirupa.com/u/psych)
#### Post date: [January 10, 2008, 2:29pm UTC](https://forum.kirupa.com/t/dynamically-adding-textfield-to-movieclip/248657/1 "2008-01-10T14:29:17Z")

</div>

I am trying to add TextField to a MovieClip using AS 3.0 with following code:

```auto
mc = new MovieClip();  
                   
mc.graphics.beginFill(0x000000);  
mc.graphics.drawRect( 0, 0, 200, 200 );  
mc.graphics.endFill();  
              
var t:TextField = new TextField();  
t.embedFonts = true;
t.antiAliasType = "advanced";
t.text = "TEST"; 
                  
var tf:TextFormat = new TextFormat();
tf.color = 0xA5C71B;
tf.size = 30;
tf.font = "Arial";
                       
t.setTextFormat(tf);
mc.addChild( t );  
                   
stage.addChild(mc);

```

But the problem is that MovieClip (black rectangle) is displayed on stage but without the text. Anyone knows what’s the problem?

thanks,  
best regards
