# TextField Problem - using addChild from the MyTextField class

**URL:** https://forum.kirupa.com/t/textfield-problem-using-addchild-from-the-mytextfield-class/264721
**Category:** flash
**Created:** [June 29, 2008, 2:21pm UTC](https://forum.kirupa.com/t/textfield-problem-using-addchild-from-the-mytextfield-class/264721 "2008-06-29T14:21:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![balajee](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@balajee](https://forum.kirupa.com/u/balajee)
#### Post date: [June 29, 2008, 2:21pm UTC](https://forum.kirupa.com/t/textfield-problem-using-addchild-from-the-mytextfield-class/264721/1 "2008-06-29T14:21:02Z")

</div>

My problem is if I am using this class as document class in flash document it works fine  
but if i use in action panel like var txt:MyTextField = new TextField();//it’s not working  
txt.testText() // this also is not working but the same testText function in flash  
action panel means it’s woking pls help me for this. and what’s the scope between class level functions  
and flash action panel functions.Thanking u

package{  
import flash.display.Sprite;  
import flash.text.\*;  
public class MyTextField extends Sprite {  
public var tField:TextField = new TextField();  
public var str:String = “Hi Friends”;  
//constructor[/COLOR]  
public function MyTextField(){  
tField.text = str; addChild(tField);  
tField.x = 150; tField.y = 100;  
}  
an

```
        public function testText(){ 
            var addField:TextField = new TextField(); 
            addField.text = str; 
            addChild(addField); 
            addField.x = 150; 
            addField.y = 100 
    }
} 

```

}

---

<div class="post-metadata">

### Author: ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)
#### Post date: [June 29, 2008, 2:26pm UTC](https://forum.kirupa.com/t/textfield-problem-using-addchild-from-the-mytextfield-class/264721/2 "2008-06-29T14:26:37Z")

</div>

you need to addChild your class in the document class.
