# Altering/expanding setTextFormat( ); function

**URL:** https://forum.kirupa.com/t/altering-expanding-settextformat-function/65142
**Category:** Uncategorized
**Created:** [September 23, 2004, 10:53am UTC](https://forum.kirupa.com/t/altering-expanding-settextformat-function/65142 "2004-09-23T10:53:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bape](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bape](https://forum.kirupa.com/u/bape)
#### Post date: [September 23, 2004, 10:53am UTC](https://forum.kirupa.com/t/altering-expanding-settextformat-function/65142/1 "2004-09-23T10:53:34Z")

</div>

Hi there, is there a way i can change the standard setTextFormat() ; function?  
I found out that after you change the text, the format sets back to default. I want to add a “on text change, settextformat again” bit but im completely lost on how to do this? something to do with prototypes doesnt it?  
Please help

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 23, 2004, 3:05pm UTC](https://forum.kirupa.com/t/altering-expanding-settextformat-function/65142/2 "2004-09-23T15:05:59Z")

</div>

this is what i have till now:

```auto

textField.prototype.setTextStyle = function(whichStyle) {
 this.onEnterFrame = function() {
  this.setTextFormat(whichStyle);
 };
};

```

Sadly it isnt working yet, and im afraid a onEnterFrame for every textfield will make it slow… any good ideas?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 23, 2004, 3:20pm UTC](https://forum.kirupa.com/t/altering-expanding-settextformat-function/65142/3 "2004-09-23T15:20:48Z")

</div>

i don’t know why the textformat reset after change.  
maybe you can try this:

textfield\_txt.onChanged = function(){  
textfield\_txt.setTextFormat(fmt);  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 23, 2004, 7:56pm UTC](https://forum.kirupa.com/t/altering-expanding-settextformat-function/65142/4 "2004-09-23T19:56:39Z")

</div>

Got it, it seems i made a typo textField instead of TextField. After that it was pretty easy. Although this isnt pretty coding, it works fine.

```auto
TextField.prototype.setTextStyle = function(whichStyle) {
 texttarget = this;
 _root.onEnterFrame = function() {
  texttarget.setTextFormat(whichStyle);
 };
};
textfield_txt.setTextStyle(fmt);

```

Anyway thanks for the help/ Bedankt voor de hulp… tis een kleine wereld 😉
