Hi to all,
i can´t figure out why i can´t combine stylesheet and settextformat together:
package marek{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.text.*;
public class renderText extends Sprite {
private var t:TextField = new TextField();
private var tf:TextFormat = new TextFormat();
private var css:StyleSheet = new StyleSheet();
public function renderText($fsize:int, $bold:Boolean, $fcolor:uint, $twidth:int, $fnt:String="Verdana") {
// CSS
this.css.parseCSS("a {color: #0000FF;} a:hover {text-decoration: underline;}");
// TextField
addChild(t);
t.antiAliasType = AntiAliasType.ADVANCED;
t.autoSize = TextFieldAutoSize.LEFT;
t.textColor = $fcolor;
//t.cacheAsBitmap = true;
if ($twidth != 0) {
t.wordWrap = true;
t.width = $twidth;
} else {
t.wordWrap = false;
}
// Textformat
tf.font = $fnt;
tf.size = $fsize;
tf.bold = $bold;
tf.align = TextFormatAlign.LEFT;
}
public function txt($txt:String, $embeddFont:Boolean=false):void {
if ($embeddFont) {
t.embedFonts = true;
//t.styleSheet = css;
t.htmlText = $txt;
} else {
t.htmlText = $txt;
}
t.setTextFormat(tf);
}
public function set letterSpacing(u:int) {
var fmt:TextFormat = t.getTextFormat();
fmt.letterSpacing = u;
t.setTextFormat(fmt);
}
}
}
before that i embbed two fonts via
[Embed(source = 'c:/FrutigerLT47LightCondensed.ttf',fontWeight = "normal",fontFamily = "FrutigerLTlightCN",embedAsCFF = "false")]
public var FrutigerLTlightCN:Class;
[Embed(source = 'c:/FrutigerLT67BoldCondensed.ttf',fontWeight = "bold",fontFamily = "FrutigerLTboldCN",embedAsCFF = "false")]
public var FrutigerLTboldCN:Class;
do somebody has a hint for me
thx in advance