Why isn't this CSS working?

Hello everybody :slight_smile:

I’m having trouble using CSS in Flash MX 2004. I’ve done it before, and I can’t seem to figure out why it isn’t working now. I am loading two things - the text from an XML file and the CSS file to apply on the textfield I will display the data in.

The textfield I’m displaying the data in is called ‘newsText’, and the two files I load from are main.php and main.css, both in the same folder as the swf that uses them.


newsText.htmlText = "Loading MySQL Data ...<br>";
output = {news:""};
style_sheet = new TextField.StyleSheet();
main = new XML();
main.ignoreWhite = true;
main.load("main.php");
main.onLoad = function(ok) {
	if (ok) {
		newsText.htmlText += "Loading CSS Data ...<br>";
		var newsSection = this.firstChild.childNodes[0];
		var newsEntries = newsSection.childNodes.length;
		for (var i = 0; i<newsEntries; i++) {
			output.news += "<p class='datum'>"+newsSection.childNodes*.childNodes[0].firstChild.toString().convertDate()+"</p>";
			output.news += "<p class='tekst'>"+unescape(newsSection.childNodes*.childNodes[1].firstChild)+"</p><br>";
		}
		style_sheet.load("main.css");
		style_sheet.onLoad = function(ok) {
			if (ok) {
				newsText.styleSheet = style_sheet;
				newsText.htmlText = output.news;
			} else {
				newsText.htmlText += "CSS File could not be loaded.";
			}
		};
	} else {
		newsText.htmlText += "MySQL data could not be loaded";
	}
};

When I test this, I see the content and none of the errors are displayed meaning that both files are correctly loaded, but for some reason the CSS isn’t applied to my textfield.

This is the content of the CSS file:

datum {
  color: #000000;
  font: standard 07_53;
  font-size: 8px;
}
tekst {
  color: #999999;
  font: standard 07_53;
  font-size: 8px;
}

That’s everything in it. I can’t figure out why Flash doesn’t apply the CSS to the textfield, can you ?