Albatross
2-22-06, 06:24 PM
I'm looking for a way to use external CSS files and external txt files to provide the content for text fields. I found a tutorial at karupa.com (Flash MX 2004) that I found did the CSS part just fine. But when I added the part that was supposed to add support for external text files, it doesn't seem to work. The text field just comes up blank now.
Here's the ActionScript for the frame the text field is in. The text field itself is named output, the external CSS file is flash.css, and the external text file is test.txt.
var format = new TextField.StyleSheet();
var path = "flash.css";
format.load(path);
format.onLoad = function(loaded) {
if(loaded) {
output.styleSheet = format;
myLoadVar = new LoadVars();
myLoadVar.load("test.txt");
myloadVar.onLoad = function(success) {
if (success == true) {
output.variable = "kirupa";
output.htmlText = myLoadVar.kirupa;
}
}
} else {
output.text = "Failed";
}
};
test.txt's contents are:
kirupa=<p>test test test</p>
The text field is set to Dynamic, multi-line no wrap, and render text as HTML.
Here's the ActionScript for the frame the text field is in. The text field itself is named output, the external CSS file is flash.css, and the external text file is test.txt.
var format = new TextField.StyleSheet();
var path = "flash.css";
format.load(path);
format.onLoad = function(loaded) {
if(loaded) {
output.styleSheet = format;
myLoadVar = new LoadVars();
myLoadVar.load("test.txt");
myloadVar.onLoad = function(success) {
if (success == true) {
output.variable = "kirupa";
output.htmlText = myLoadVar.kirupa;
}
}
} else {
output.text = "Failed";
}
};
test.txt's contents are:
kirupa=<p>test test test</p>
The text field is set to Dynamic, multi-line no wrap, and render text as HTML.