I am creating a text class for label purposes with the code below. This works as expected when added to stage within a container. But after reassigning the textfield.text a different text, all the formatting is gone. What is the solution, please?
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
public class getLabel extends Sprite{
public var lbl:TextField = new TextField();
private var lblformat:TextFormat = new TextFormat();
public function getLabel(){
lbl.type=TextFieldType.DYNAMIC;
lbl.text="Initial Text";
lbl.selectable=false;
lbl.autoSize = TextFieldAutoSize.LEFT;
lbl.selectable = false;
lbl.background = true;
lblformat.color = 0xFF0000;
lblformat.size = 14;
lbl.setTextFormat(lblformat);
this.addChild(lbl);
}
}
}