change text of TLFTextField through constructor

38 Views Asked by At

I have a symbol which extends MovieClip and it has a TLFTextField instance in it. I try to change the text of the TLFTextField in the constructor, like this:

public function mySymbol() 
{
    myTLF.text = "texty text";
}

I create a new instance of the class mySymbol in my DocumentClass:

public function DocumentClass() 
{
    var mySymbol:MySymbol = new MySymbol();
    addChild(mySymbol);
}

The symbol is created and added to stage (I know that because it has a border and background color) but nothing shows up inside myTLF.

If instead of trying to change the text in the constructor, I change it in the DocumentClass() (using mySymbol.myTLF.text = "texty text"; it does show up.

What am I missing here?

1

There are 1 best solutions below

0
OzW On

Just so that this question doesn't stay open, I followed the recipe in this question: I added an event listener for Event.ADDED_TO_STAGE on the symbol holding the TLFTextField, and in the event handler I could change the text.