I can’t find out how to apply a stylesheet to a text field. It just does not work.
This is the css:
p {
font-size: 24;
font-family: Verdana, Geneva, sans-serif;
font-style: italic;
color: #006666;
}
This is the html:
<p>first line</p>
And the whole application is very simple. It loads the html and css and applies them to TextField. It looks like the only rule that gets applied is the font-style: italic; - the text displayed on the stage is 12px, black and Times New Roman and italic
Why?
And here is the whole application code:
stop();
import flash.text.TextField;
import flash.events.Event;
import flash.text.StyleSheet;
import flash.net.URLLoader;
var htmlLoader:URLLoader;
var cssLoader:URLLoader;
var tf:TextField = new TextField();
tf.width = 300;
addChild(tf);
htmlLoader = new URLLoader();
htmlLoader.addEventListener(Event.COMPLETE, htmlLoaded);
var htmlRequest:URLRequest = new URLRequest("html.html");
htmlLoader.load(htmlRequest);
cssLoader = new URLLoader();
cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
var cssRequest:URLRequest = new URLRequest("css.css");
cssLoader.load(cssRequest);
function htmlLoaded(event:Event):void {
var myHtml:String = htmlLoader.data;
tf.htmlText = myHtml;
}
function cssLoaded(event:Event):void {
var myCss:String = cssLoader.data;
var style:StyleSheet = new StyleSheet();
style.parseCSS(myCss);
tf.styleSheet = style;
trace (tf.htmlText);
}