[MX] Loading Text

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;
};

:love:
~Seretha

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”.

I hope this helps :slight_smile:

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.

:love:
~Seretha

Huh?

This line here…

scroller.text = “”;

Clears the textbox so that the scrollbar starts at the top again.

It works perfectly great for me :-\

Here is the file I tested it in.

You can scope it out if you want.

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.

:love:
~Seretha

Goodnight Seretha!

Its 3am here, maybe I should be doing the same…lol.

No problem with the help, if I can help, I do help :slight_smile: