Hi,

Attached below is a section of code from a larger script that I have simplified for demonstartion purposes.

What I would like to do is load in a .txt file that contains a variable declaration & assignment, like:

past=Lemons are a nice fruit said tick.

So far, so good, now when the variables are loaded in I have set the “vars” onLoad function to process the string of text contained in the variable & make certain text style alterations to a word, if it is found.

Now I have got the whole thing working great IF I hardwire a variable value into the value expected by the parameters of the function that alters the text:

alterText(this.past,“tick");

However, if I set the parameter dynamically, such as:

code:
when_array = [past,present]

for (var g = 0; g<=0; g++) {
var tom = _root.when_array[g];
_root.varLoader_array[g] = new LoadVars();
_root.varLoader_array[g].onLoad = function() {
alterText(this.tom, "tick");
trace(tom);
};
_root.varLoader_array[g].load(loadHold_array[g]);
}



All hell breaks lose & I have to shut flash down to get out of what appears to be an endless loop!

Any ideas please, Full script set out below:

code:
when_array = [past,present];
varLoader_array = new Array();
loadHold_array = ["tick.txt", "tock.txt"];
/////////////////////////////////////////////////////////
function alterText(theString_str, card_str) {
var textSplit_array = new Array();
var holdString_str = new String();
var colorCard_str = "<font face='pristina' size='24' color='#FF0000'>"+card_str+"</font>";
textSplit_array = theString_str.split(card_str);
///////////////////////////////////////////////////////////////////////////////////////////
for (var a = 0; a<=textSplit_array.length-1; a++) {
if (a<=textSplit_array.length-2) {
my_txt.htmlText += textSplit_array[a]+colorCard_str;
} else {
my_txt.htmlText += textSplit_array[a];
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
for (var g = 0; g<=0; g++) {
var tom = _root.when_array[g];
_root.varLoader_array[g] = new LoadVars();
_root.varLoader_array[g].onLoad = function() {
alterText(this.tom, "tick");

};
_root.varLoader_array[g].load(loadHold_array[g]);
}