Hi all.
I’m trying to use FlashCS3 to set up a “fast facts” feature on my website where on loading the page a random fact is pulled from an external file and displayed in the dynamic text box. I’d also like the text that’s displayed to take advantage of html and css formatting.
I’ve read the tutorial from this website on loading dynamic text from external files (code included below) and also the tutorial on using CSS for dynamic text (code also included below) but I can’t seem to get them to work together. I understand that the textbox names and variables in the two pieces of code are different and I adjusted for that.
I’d really appreciate any help.
Thanks,
Michael
Code for loading text from external file:
ranQuote = new LoadVars();
ranQuote.onLoad = function(success) {
if (success) {
RanNum = Math.ceil(Math.random()5);
ran = this[“quote”+RanNum];
quote_txt.text = ran;
}
else {
quote_txt.text = “The text failed to load due to an error”;
}
}
ranQuote.load(“Quotes.txt”);
stop();
**
Code for using CSS styles in flash*
var format = new TextField.StyleSheet();
var path = “http://www.kirupa.com/developer/mx2004/code/flash.css”;
var quick = “<br><p class=‘one’>The quick Kirupa jumps over the lazy dog.</p><br><p class=‘two’>The quick Kirupa jumps over the lazy dog.</p><br><p class=‘three’>The quick Kirupa jumps over the lazy dog.</p><br><p class=‘four’>The quick Kirupa jumps over the lazy dog.</p>”;
format.load(path);
format.onLoad = function(loaded) {
if (loaded) {
output.styleSheet = format;
output.text = quick;
} else {
output.text = “Error loading CSS file!”;
}
};