I recently built for my framework Soma a subclass of the TextField Flash built-in class to be able to easily use styles with a textfield: SomaText.

I’ve extracted SomaText from the framework to be able to use it without Soma. It has powerful features such as default values, default stylesheet and styles. SomaText is able to parse the stylesheet to apply TextField and TextFormat properties straight from the stylesheet. You can also get a full description of the properties and styles applied by tracing the SomaText instance.

SomaText can be used as a label or as a more complicated TextField with HTML tags.

You will be fine with SomaText as it is extending the TextField class and SomaText also shorten the syntax when you create instances.

You can download the SomaText sources and documentation in the SomaText page.

The SomaText standalone is slightly different than the one in the framework (the global stylesheet registration is different), but you can find some explanation in the SomaProtest stylesheet page.

See a full list of CSS properties you can use with SomaText.

As a quick example, here are some SomaText syntax:

SomaText.globalStyleSheet = _globalStylesheetLoaded;
// text
var s1:SomaText = new SomaText("simple text");
addChild(s1);
// text with style from the global stylesheet
var s2:SomaText = new SomaText("text with style from the global stylesheet", "simpleStyle");
addChild(s2);
// text with style from another stylesheet
var s3:SomaText = new SomaText("text with style from another stylesheet", "simpleStyle", _customStylesheet);
addChild(s3);
// multiline text with properties set in actionscript
var s4:SomaText = new SomaText("multiline text with textfield properties modified in the actionscript: width, multiline, wordWrap, selectable, and so on.", "defaultText");
s4.width = 220;
s4.multiline = true;
s4.wordWrap = true;
s4.selectable = true;
// can be set in the constructor or using the setProperties method:
//s4.setProperties({width: 220, multiline: true, wordWrap: true, selectable: true});
addChild(s4);
// multiline text with properties set in the stylesheet
var s5:SomaText = new SomaText("multiline text with textfield properties set in the stylesheet: width, multiline, word-wrap, selectable, and so on.", "defaultTextMultiline");
addChild(s5);

And the global stylesheet used:

.defaultTextMultiline {
font-family: "Arial";
font-size: 11;
color: #2C384E;
width: 220;
multiline: true;
word-wrap: true;
selectable: true;
}
a {
color: #002F7D;
}
a:hover {
color: #5C2E2E;
text-decoration: underline;
}
.simpleStyle {
font-family: "Arial";
font-size: 16;
color: #8DA0C0;
}
.defaultText {
font-family: "Arial";
font-size: 11;
color: #2C384E;
}
.para {
font-family: "Arial";
font-size: 18;
color: #004040;
}
.color1 {
color: #C1540B;
}

Share and Enjoy!