Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading xml into textfield and styling it with external css

Status
Not open for further replies.

maguskrool

Technical User
Dec 11, 2006
77
PT
Hi.

I have a dynamic text field on the Stage, named txt01. I'm trying to load text into it, from a .xml file (text_01.xml) and have it formatted through an external .css file (css_01.css) that I'll load into Flash as well. I've tried checking and unchecking the "render text as html" option but the results were the same.

When I test the movie, I see the bold and italic text correctly, but none of the other formatting described in the .css. Using getStyleNames displays the correct styles defined in css_01.css, so I know they are loaded correctly.

I've seen the example described here:

and it works mostly like mine, except it loads the text from a .txt and not a .xml file, and there the css works perfectly. I do need to use .xml however, so trying a .txt is not an option. Any clues on what's wrong and how I might get it to work?

Thank you for your time.


CODE:
Code:
//FLASH, AS2
//1ST FRAME
var style_sheet:TextField.StyleSheet = new TextField.StyleSheet ();
var my_xml:XML = new XML ();
my_xml.ignoreWhite = true;
//
style_sheet.onLoad = function (success:Boolean):Void  {
	if (success) {
		txt01.styleSheet = style_sheet;
		my_xml.load ("text_01.xml");
	} else {
		trace ("Error loading CSS.");
	}
};

//
my_xml.onLoad = function (success:Boolean):Void  {
	if (success) {
		txt01.text = my_xml;
	} else {
		trace ("Error loading XML.");
	}
};
//
style_sheet.load ("css_01.css");

//XML (text_01.xml)
<?xml version="1.0" encoding="UTF-8"?>
<mytext>This <biggy>text</biggy> should be<b>bold</b> or <i>italic</i>, please.</mytext>

//CSS (css_01.css)
.biggy{
	font-size: 36px;
	color:#006600;
}
b {
	font-size: 16px;
	color:#336633;
}
 
I'm trying the above example. The XML loads fine. But I'm getting "Error loading CSS."

any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top