I’m loading external text files into a textbox when you click buttons, like so:
blueBtn.onRelease=function(){
loadText=new LoadVars();
loadText.load("blueText.txt");
loadText.onLoad=function(success){
if(success){
newsBox.html=true;
newsBox.htmlText=this.myNews;
}
}
}
This works fine, no problem. But I’ve got a bunch of buttons. So, I write this as a function:
function grabText(file, fileVar) {
loadText = new LoadVars();
loadText.load(file);
loadText.onLoad = function(success) {
if (success) {
trace("I have your data, Commander.")
newsBox.html = true;
newsBox.htmlText = file.fileVar;
}
};
}
blueBtn.onRelease = function() {
grabText("blueText.txt", "myNews");
};
And then I have trouble. The trace works fine, but “undefined” appears in the textbox.
Any ideas what I’m doing wrong? I’m sure it’s something simple/stupid, but I can’t find it. Thanks!