# Guru wonted! global TextFormat Problem

**URL:** <https://forum.kirupa.com/t/guru-wonted-global-textformat-problem/25990>\
**Category:** flash\
**Created:** [July 18, 2003, 10:18am UTC](https://forum.kirupa.com/t/guru-wonted-global-textformat-problem/25990 "2003-07-18T10:18:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mediaholic](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@mediaholic](https://forum.kirupa.com/u/mediaholic)\
**Post date:** [July 18, 2003, 10:18am UTC](https://forum.kirupa.com/t/guru-wonted-global-textformat-problem/25990/1 "2003-07-18T10:18:46Z")

</div>

as u probably know TextFormat has no global style  
like FStyleFormat so i thought i could make one?

1. idea)  
i could wrap createTextField() in some fns which then assigns automaticly some TextField-propertys and sets setTextFormat.  
THE PROBLEM  
with that is that not all of my TextFields are generated via script, some r created by authoring-time.

2. idea)  
is to change the prototype.“someproperty” of the TextField,  
THE PROBLEM  
TextField is not created via standard “new” constructor  
so something like TextField.prototype.embedFonts=true;  
DOES NOT WORK as well.

3. idea)  
i could simply traverse all instances on stage and ask if the instanz is TextFeld and then assgin some fns which makes the formating  
THE PROBLEM  
i dont know how to do that?🙂

## couse if i ask trace(typeof t\_txt. **proto** ); it just givs “object” not TextField or so

**does anybody knows how to make kind of global TextFormat  
for createTextField()-generated as well as for authoring-time generated TextFields?**

this is very general problem, so i think i can’t be the only one with that problem:

---

<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:** [July 18, 2003, 11:58am UTC](https://forum.kirupa.com/t/guru-wonted-global-textformat-problem/25990/2 "2003-07-18T11:58:44Z")

</div>

1, 2)  
[AS]MovieClip.prototype.$createTextField = MovieClip.prototype.createTextField;  
MovieClip.prototype.createTextField = function(instanceName, depth, x, y, width, height) {  
if (arguments.length\<6) {  
return undefined;  
}  
this.$createTextField(instanceName, depth, x, y, width, height);  
this[instanceName].defaultTextFormat();  
return this[instanceName];  
};  
ASSetPropFlags(MovieClip.prototype, null, 1, 0);  
TextField.prototype.defaultTextFormat = function() {  
// add TextField properties here  
var myTextFormat = new TextFormat();  
// add TextFormat properties here  
this.setNewTextFormat(myTextFormat);  
this.setTextFormat(myTextFormat);  
};  
ASSetPropFlags(TextField.prototype, null, 1, 0);[/AS]  
3)  
[AS]for (var obj in this) {  
if (this[obj] instanceof TextField) {  
this[obj].defaultTextFormat();  
}  
}[/AS]  
Does that 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:** [July 19, 2003, 7:19pm UTC](https://forum.kirupa.com/t/guru-wonted-global-textformat-problem/25990/3 "2003-07-19T19:19:07Z")

</div>

hmmm tnx for that, in meentime  
i solve it on the other way.  
and if i my say that(correct me if i’m wrong) my version seems better to me.  
please have a look maybe u find some drawback.

in u’re version i dont know way schould i wrap all that in  
extra object, exept if that solves the problem with components?

i noticed that at least in my version, if some components r on the stage the for-loop become endless so i use this static style\_all\_tf.protokoll to solve that.  
any incitation?

style\_all\_tf.protokoll = new Array();  
function style\_all\_tf(parent) {  
for (e in parent) {  
if (parent[e] instanceof MovieClip) {  
var new\_one = true;  
for (var i = 0; i\<arguments.callee.protokoll.length; i++) {  
if (parent[e] == arguments.callee.protokoll\*) {  
new\_one = false;  
}  
}  
if (new\_one) {  
arguments.callee.protokoll[arguments.callee.protokoll.length] = parent[e];  
arguments.callee(parent[e]);  
}  
} else if (parent[e] instanceof TextField) {  
if (parent[e].type == “input”) {  
global\_itf\_style(parent[e]);  
} else {  
global\_dtf\_style(parent[e]);  
}  
}  
}  
}  
//in \_root timeline a call  
style\_all\_tf(this);
