[AS3 SNIPPET] Set links style of specified TextField using CSS

1
2
3
4
5
6
7
8
9
public static function setLinksStyle(tf : TextField, linkColor : Number = 0x000000, linkHoverColor : Number = 0x666666, underline : Boolean = true) : void
{
var _underline : String = underline ? "underline" : "none";

var ss : StyleSheet = new StyleSheet();
ss.parseCSS("a:link {color: " + ColorUtil.hex2css(linkColor) + "; text-decoration: " + _underline + ";}" + "a:hover {color: " + ColorUtil.hex2css(linkHoverColor) + "; text-decoration: " + _underline + ";}");

 tf.styleSheet = ss;
}

You can find the ColorUtil class here.