PDA

View Full Version : can't trigger function twice



j0se
February 12th, 2003, 09:09 AM
hi guys! :beam: i've not been been flashing lately (hence my absence) :trout: until now :rambo:

ok, i have a function that loads a text file into a textbox

i call the function from a series of menu buttons (about us, clients etc...)

both the function and the textbox are on the main time line (the textbox is in an mc instance named "text_mc"

the function triggers when i click any button - but won't trigger again after that

button code:
on(press){
loadText("services.txt");
}

function code:
function loadText(fileToLoad){
loadText = new loadVars();
loadText.load(fileToLoad);
loadText.onLoad = function(success) {
if (success){
//load the text file [look for a var named "fileText"]
//into the dynamic textbox [txtBox]
_root.text_mc.txtBox.text = this.fileText;
} else {
.
.
.


** if i put both bits of code behind each button it works fine (but i obviously don't want to do that)

ok, many cheers if anybody can help
:smirk:

h88
February 12th, 2003, 09:57 AM
Did you try _global?


_global.loadText = function(fileToLoad) {
loadText = new LoadVars();
loadText.onLoad = function(success) {
if (success) {
//load the text file [look for a var named "fileText"]
//into the dynamic textbox [txtBox]
_root.text_mc.txtBox.text = this.fileText;
} else {
trace("Error Loading "+fileToLoad);
}
};
loadText.load(fileToLoad);
};
loadText("textfile.txt");