Hello All, I’ve got the following script working for random quotes
var format = new TextField.StyleSheet();
var path = “quotes.css”;
format.load(path);
format.onLoad = function(success) {
if (success) {
output.styleSheet = format;
myLoadVar = new LoadVars ();
myLoadVar.load(“Quotes.txt”)
myLoadVar.onLoad = function (success){
if (success == true) {
RanNum = Math.ceil(Math.random()*5);
ran = this[“quote”+RanNum];
output.htmlText = ran;
}
}
} else {
output.text = “Error loading CSS file!”;
}
};
My TASK is that, once i finish this project, someone else WITHOUT Flash Knowledge will be maintaining this. So what i wanted to do is create a .txt file for them to edit so they can put as many QUOTES as they want. NOw the problem is that the following “RanNum = Math.ceil(Math.random()*5);” will look for 5 quotes in the TXT file, if i go any lower than 5 for example 2, I get UNDEFINED for those 3 that aren’t in there.
How do i get FLASH to go through the .txt FILE and automatically change “5” to the # of Quotes in the file?
FORMAT of .txt file:
quote1=<p class=‘quote’>Test1</p>
"e2=<p class=‘quote’>Test2</p>
"e3=<p class=‘quote’>Test3</p>
"e4=<p class=‘quote’>Test4</p>
Appreciate any help that i can get. Thanks.