You could do this a number of ways. One way would just be to make a TextFormat and assign it a global reference:
ActionScript Code:
_global.myTF = new TextFormat();
myTF.color = 0x000000;
myTF.font = "arial";
myTF.size = 10;
Then on any text field , you can just use setTextFormat(myTF).
If you want to make that whole process even more generalized, you could write a custom method, something like this:
ActionScript Code:
MovieClip.prototype.newTextField = function(textString) {
this.createTextField("test_txt", 0, 0, 0, 100, 20);
with (this.test_txt) {
selectable = false;
text = textString;
setTextFormat(myTF);
} // end with (this.test_txt)
} // end newTextField() method
Then, any time you needed to create a textfield, you could just do it like this (creating it on the _root):
ActionScript Code:
var textString = "Hello World!";
_root.newTextField(textString);
You could modify it so as to pass various parameters too:
ActionScript Code:
MovieClip.prototype.newTextField = function(textString, fieldName, args) {
// textString: the text string to be displayed in the field
// fieldName: the name of the textftield
// args is an object with the following properties:
/*
format: the reference to a textformat object
x: the x coordinate
y: the y coordinate
width: the width of the field
height: the height of the field
selectable: true or false
html: true or false
border: true or false
borderColor: the hex color
multililine: true or false
wordWrap: true or false
etc... all the textfield properties you need
*/
// initialize the properties
if (textString == undefined) textString = "hello world";
if (fieldName == undefined) fieldName = "myText_txt";
if (args == undefined) var args = new Object();
if (args.format == undefined) args.format = myTF;
if (args.x == undefined) args.x = 0;
if (args.y == undefined) args.y = 0;
if (args.width == undefined) args.width = 100;
if (args.height == undefined) args.height = 20;
if (args.selectable == undefined) args.selectable = false;
if (args.html == undefined) args.html = false;
if (args.border == undefined) args.border = false;
if (args.borderColor == undefined) args.borderColor = 0x000000;
if (args.multiline == undefined) args.multiline = false;
if (args.wordWrap == undefined) args.wordWrap = false;
// etc. etc. for all properties you want
// render the textfield
this.createTextField(fieldName, theDepth++, args.x, args.y, args.width, args.height);
with (this[fieldName]) {
selectable = args.selectable;
border = args.border;
borderColor = args.borderColor;
multiline = args.multiline;
wordWrap = args.wordWrap;
if (args.html == true) {
html = true;
htmltext = textString;
} else {
text = textString;
} // end if (args.html == true)
if (args.format != undefined) setTextFormat(args.format);
} // end with (this[fieldName])
} // end newTextField() method
Then you could set up an object with the correct properties and pass it to the textfields you create:
ActionScript Code:
// this is the textformat
var myTF = new TextFormat();
myTF.font = "arial";
myTF.size = 10;
myTF.color = 0x000000;
// this is the object which will be passed as args
var textProps = new Object();
textProps.format = myTF;
textProps.x = 10;
textProps.y = 10;
textProps.width = 150;
textProps.height = 100;
textProps.html = true;
textProps.multiline = true;
textProps.wordWrap = true;
// this is the string that will be passed
var myTextString = "This is a long text field that will be rendered
in html text, with multiple lines and automatic word wrapping.
The text is arial, 10 pt typeface, of black color.";
// pass those arguments to the newTextField() method
_root.newTextField(myTextString, "test_txt", textProps);
// for a different textfield, just modify the properties of textProps:
textProps.y = 120;
var myTextString2 = "This is another long textfield that will be rendered . . . ";
// create another textfield
_root.newTextField(myTextString2, "test2_txt", textProps);
Something like that should work.