TextField Problem - using addChild from the MyTextField class

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 
    }
} 

}

you need to addChild your class in the document class.