Guru wonted! global TextFormat Problem

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?:slight_smile:

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:

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? =)

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);