# TextFormat won't stick

**URL:** <https://forum.kirupa.com/t/textformat-wont-stick/256292>\
**Category:** flash\
**Created:** [April 1, 2008, 6:00pm UTC](https://forum.kirupa.com/t/textformat-wont-stick/256292 "2008-04-01T18:00:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hobbbz](https://avatars.discourse-cdn.com/v4/letter/h/54ee81/32.png) [@hobbbz](https://forum.kirupa.com/u/hobbbz)\
**Post date:** [April 1, 2008, 6:00pm UTC](https://forum.kirupa.com/t/textformat-wont-stick/256292/1 "2008-04-01T18:00:21Z")

</div>

Check this out  
[http://juliankussman.com/blog/wp-content/uploads/2008/04/textformatsticking.swf](http://juliankussman.com/blog/wp-content/uploads/2008/04/textformatsticking.swf)

Click the button to change the text. Then at some point, click on the text and then click the button again. The defaultTextFormat goes away.

Here is the code:

```auto
var titleTF:TextFormat = new TextFormat();
titleTF.color = 0xFF00FF;
titleTF.size = 22;
//titleTF.font = avantBold.fontName;
var titleText:TextField = createTF(10, 10, 200, 26, true, titleTF, &#8220;This is a test&#8221;);
addChild(titleText);
 function createTF(_x:Number, _y:Number, _width:Number, _height:Number, _autoSize:Boolean, _defaultTF:TextFormat, _text:String):TextField {[INDENT] var tf:TextField = new TextField();
tf.x = _x;
tf.y = _y;
tf.width = _width;
tf.height = _height;
tf.autoSize = (_autoSize) ? TextFieldAutoSize.LEFT : TextFieldAutoSize.NONE;
tf.wordWrap = true;
tf.multiline = true;
tf.defaultTextFormat = _defaultTF;
tf.htmlText = _text;
//tf.setTextFormat(_defaultTF);
return tf;
[/INDENT]}
 clicker.addEventListener(MouseEvent.CLICK, swapText);
 function swapText(e:*):void{[INDENT] titleText.htmlText = &#8220;This is now a changed test&#8221; + String(Math.random());
[/INDENT]}
                                   

```

Any help?
