htmlText not working
My general problem is that I'm trying to change dynamic text (using button rollovers), but the buttons wipe out formatting that I apply in Flash properties, so I'm trying to use HTML styles instead. I'm using an AS2 file.
The strings I want to change are super short, so rather than create HTML files for each one, I'm wanting to change the strings in AS.
Bizarrely, however, I don't seem able to change the string in AS unless everything is loaded from an external file. Here is example code from the AS2 manual. And when I use the final line, it doesn't work.
this.createTextField("news_txt", 99, 50, 50, 450, 300);
news_txt.border = true;
news_txt.html = true;
news_txt.multiline = true;
news_txt.wordWrap = true;
var myVars_lv:LoadVars = new LoadVars();
var styles:TextField.StyleSheet = new TextField.StyleSheet();
var txt_url:String = "myText.htm";
var css_url:String = "html_styles.css";
styles.onLoad = function(success:Boolean):Void {
if (success) {
news_txt.styleSheet = styles;
} else {
trace("Unable to load CSS file.");
}
};
styles.load(css_url);
myVars_lv.onData = function(src:String):Void {
if (src != undefined) {
news_txt.htmlText = src;
} else {
trace("Unable to load HTML file");
}
};
//myVars_lv.load(txt_url); // with just this line, it works fine
news_txt.htmlText = '<p class="headline">hello world</p>'; // adding this just results in unstyled text
What am I doing wrong? It seems like it must be something simple. A config problem? I'm using CS4.
Thanks,
Tim