Skip to main content
David_MB
Participant
February 17, 2009
Question

How do I style XML text with CSS?

  • February 17, 2009
  • 1 reply
  • 414 views
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?
This topic has been closed for replies.

1 reply

David_MB
David_MBAuthor
Participant
February 17, 2009
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;

}

--------------------------------------------