# Changeable Dynamic Text Class

**URL:** <https://forum.kirupa.com/t/changeable-dynamic-text-class/317442>\
**Category:** flash\
**Created:** [December 20, 2010, 8:14pm UTC](https://forum.kirupa.com/t/changeable-dynamic-text-class/317442 "2010-12-20T20:14:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zik80](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@zik80](https://forum.kirupa.com/u/zik80)\
**Post date:** [December 20, 2010, 8:14pm UTC](https://forum.kirupa.com/t/changeable-dynamic-text-class/317442/1 "2010-12-20T20:14:11Z")

</div>

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?

```auto
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);
        }
    }
}

```
