0
How do I style XML text with CSS?
Explorer
,
/t5/animate-discussions/how-do-i-style-xml-text-with-css/td-p/173420
Feb 17, 2009
Feb 17, 2009
Copy link to clipboard
Copied
How do I load a CSS stylesheet to format XML text that is
loaded into the swf using AS3? The goal is to assign hyperlinks to
a list of text. The only way I can find to do that is CSS formatted
XML. However, there is very, very little information on how to load
and apply CSS to XML text using AS3.
Anyone know how to do this?
Anyone know how to do this?
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
David_MB
AUTHOR
Explorer
,
LATEST
/t5/animate-discussions/how-do-i-style-xml-text-with-css/m-p/173421#M6145
Feb 17, 2009
Feb 17, 2009
Copy link to clipboard
Copied
Nevermind I figured it out. But.......... just in case anyone
wants to know this.................
Here is the code that will apply a CSS stylesheet called "viewerData.css" to a text field called "list1" who's content is loaded from a XML file called "viewerData.xml" Basically this allows me to load a list of names into a text field with hyperlinks attached to them.
--------------------------------
var css:StyleSheet;
var cssLoader:URLLoader = new URLLoader();
cssLoader.load(new URLRequest("viewer_data/viewerData.css"));
cssLoader.addEventListener(Event.COMPLETE, processCSS);
function processCSS(e:Event):void {
//trace("stuff");
}
var dataXML:XML;
var XMLLoader:URLLoader = new URLLoader();
XMLLoader.load(new URLRequest("viewer_data/viewerData.xml"));
XMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
dataXML = new XML(e.target.data);
var linkData:String = dataXML.nameList;
this.list1.styleSheet = css;
this.list1.htmlText = linkData;
}
--------------------------------------------
Here is the code that will apply a CSS stylesheet called "viewerData.css" to a text field called "list1" who's content is loaded from a XML file called "viewerData.xml" Basically this allows me to load a list of names into a text field with hyperlinks attached to them.
--------------------------------
var css:StyleSheet;
var cssLoader:URLLoader = new URLLoader();
cssLoader.load(new URLRequest("viewer_data/viewerData.css"));
cssLoader.addEventListener(Event.COMPLETE, processCSS);
function processCSS(e:Event):void {
//trace("stuff");
}
var dataXML:XML;
var XMLLoader:URLLoader = new URLLoader();
XMLLoader.load(new URLRequest("viewer_data/viewerData.xml"));
XMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
dataXML = new XML(e.target.data);
var linkData:String = dataXML.nameList;
this.list1.styleSheet = css;
this.list1.htmlText = linkData;
}
--------------------------------------------
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

