AS3: Re-Usable TextFormat class
In this simple tip I provide an easy to use text formatting class. To use this class, simply import the class into your existing document class or other, and then create a variable instance. To call the formatter you will use “textfield.setTextFormat(variable.formatfunction);
The formatting class is below:
package com.riareviver{ //FLASH CLASS IMPORT import flash.display.MovieClip; import flash.events.*; import flash.text.TextFormat; public class TxtFormat extends MovieClip { //VAR public var myTextFormat:TextFormat = new TextFormat(); public function TxtFormat() { //TEXT FORMATTER myTextFormat.font = "Verdana"; myTextFormat.color = 0xFFFFFF; myTextFormat.size = 10; myTextFormat.align = "left"; } } }
Below is a sample textfield class using the formatter
package com.riareviver{ //FLASH CLASS IMPORT //CUSTOM CLASS IMPORT import com.riareviver.TxtFormat; public class MyText extends MovieClip { //PUBLIC VARS //PRIVATE VARS private var myTextField:TextField; private var txtFormat:TxtFormat = new TxtFormat(); public function MyText() { myTextField = new TextField(); myTextField.x = 5; myTextField.y = 5; myTextField.width = 200; myTextField.text = "My Text"; myTextField.setTextFormat(txtFormat.myTextFormat); myTextField.selectable = false; addChild(myTextField); } } }
Click here to see more text formatting properties

Recent Comments
GarthDB on FlashBuilder: SourceMate AS3Signals Template:
Thanks Brian. I appreciate this being here....
kathryn on I have joined litl!:
psyched to have you onboard! this team just gets more and more awesome....
Filippo on My FlashBuilder 4 color scheme.:
Flash Builder is such a powerful tool, but syntax highlighting just sucks! ...
Devi on AS3: Creating custom events:
This example is awesome...
Josh Molina on AS3: Creating custom events:
Excellent tutorial. Straight and to the point.Thank you.Jo...