I’m trying to just figure out how to style text imported via xml with css. Here’s the code I have. It imports the XML just fine, but there is no style. I’ve also included the xml + css files.
Any ideas?
Actionscript:
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
loadCSS();
function loadCSS() {
trace("loadCSS");
var cssLoader:URLLoader = new URLLoader();
cssLoader.load(new URLRequest("test.css"));
cssLoader.addEventListener(Event.COMPLETE, cssComplete);
}
function cssComplete(e:Event) {
trace("cssComplete");
var sheet:StyleSheet = new StyleSheet();
sheet.parseCSS(e.target.data);
textObj.styleSheet = sheet;
loadXML();
}
function loadXML() {
trace("loadXML");
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("forcss.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlComplete);
}
function xmlComplete(e:Event):void {
trace("xmlComplete");
var xml:XML = new XML(e.target.data);
textObj.htmlText = xml.point[0];
}
XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<point><=!=[=C=D=A=T=A=[<h1 class="test">Test</h1><br><br><p>test test test test </p><p>test test etst ste</p>]=]=></point>
</data>
CSS:
.test {
font-size: 20px;
color: #0000ff;
}