Can’t get the CSS to style an external txt. Copy loads as supposed to and thru a trace I can see that the css stylesheet is recognized but it won’t actually style the text. For instance, <span class=“header”> Heading</span>stays at the original font size instead of getting bigger. I’m stumped. Have tried so many things to get this to work. What have I missed?
Instance name of dynamic text field = upcom_txt. Text field is on stage. Html, check. Multiline, check.
the css style sheet = “CSSs/news.css”
my text = “TXTs/upcom.txt”
Font = “Alte Haas Grotesk”. The font is a font symbol exported from the library of the FLA. (I’ve tried using a system font, but it still doesn’t work)
CSS FILE:
p {
color: #ffffff;
font-size: 12px;
}
a:link {
color: #000000;
text-decoration: underline;
}
a:hover{
color: #999999;
text-decoration: none;
}
.header {
color: #FFFFFF;
font-size: 20px;
font-weight: bold;
display: block;
}
.subhead {
color: #666600;
font-style: italic;
font-size: 16px;
font-weight: bold;
display: inline;
}
AS CODE on timeline to load stylesheet first and then upcom.txt:
function cssLoadComplete(event:Event):void
{
styles.parseCSS(event.target.data);
// Now assign the StyleSheet to a text field for example
upcom_txt.styleSheet = styles;
// Now you would load any external text or html into
// the text field
function textLoadComplete(event:Event):void {
upcom_txt.htmlText = textLoader.data;
}
var textLoader:URLLoader = new URLLoader();
var textReq:URLRequest = new URLRequest("TXTs/upcom.txt");
textLoader.load(textReq);
textLoader.addEventListener(Event.COMPLETE, textLoadComplete);
}
var cssLoader:URLLoader = new URLLoader();
var cssRequest:URLRequest = new URLRequest("CSSs/news.css");
var styles:StyleSheet = new StyleSheet();
cssLoader.load(cssRequest);
cssLoader.addEventListener(Event.COMPLETE, cssLoadComplete);
}
Text file:
<span class='header'>First announcement</span>
<span class='subhead'>This is a subhead for URLS and such</span>
<p>This is where we will show off a bunch of announcements in blog format. This is where we will show off a bunch of announcements in blog format. This is where we will show off a bunch of announcements in blog format.This is where we will show off a bunch of announcements in blog format.This is where we will show off a bunch of announcements in blog format </p>
Anyone see why there would be a problem? Thank you in advance. I’ve really appreciated the help.