I was working on the dynmaic loading text tutorial earlier today but when I use it on my page and try to get the text in the scroller to change to the new pages text…nothing happens…i’ve tried everything i can think of… i’ve posted the code that is in the tutorial i was learning. i need to know how to replace that files text with new text when someone clicks on a button. (I don’t want the whole page to refresh…just the text in the scroller)
------------------- ugly code--------
loadText = new loadVars();
loadText.load(“kirupa.txt”);
//creating the loadVarsText function
loadText.onLoad = function() {
scroller.text = this.kirupatext;
};
Alright, I came up with a prototype method. I hope you don’t mind prototypes :beam:
//create loadVars
loadText = new loadVars();
//create prototype function
MovieClip.prototype.changeText = function(file, myVar) {
//clear text box
scroller.text = "";
//load the file (dependant on variable from inside function
loadText.load(file);
//what do to after it loads
loadText.onLoad = function() {
//display the text using the variable defined in the function
scroller.text = this[myVar];
};
};
//launch default file
changeText("kirupa.txt", "kirupatext");
I commented the code above so if you have any questions about anything in particular I can explain further.
Now on your button you will call the prototype like this…
on (release) {
changeText("newFile.txt", "newVar");
}
“newFile.txt” is of course the file you are going to load.
“newVar” is the variable that contains your text. Like in the tutorial it is “kirupatext”.
What would I ever do without you beta? It works great … of course… and the only prob i am having is that I can’t make the text load to the top of the scroller as it apparantly feels more comfortable in the middle… but I’m going to mess around and I’m sure i’ll be able to figure that out.
Yea… just another stupid mistake on my behalf. Thanks again Beta. You’re a sweetheart. It’s working great so I can finally let myself go to bed. Goodnight and i really appreciate all the help you’ve given me.