Buttons to load text?

How can I adapt this code for use with a button instead of a frame action?

loadText = new loadVars();
loadText.load(“lamplight.txt”);
//creating the loadVarsText function
loadText.onLoad = function() {
scroller.text = this.lamplighttext;
};

I’m using it to load .txt files into a text box. I would like to have two buttons for the user to select the text they want.

Thanks in advance…

-P.

Howdy…

Are you looking for this???

yourButtonInstance.onPress = function ()
{
     // your full code goes here...
}

???

No, that didn’t seem to work…

Should I attach that code to my button?

-P.

Um… That’s exactly what I have meanted…

I am using the dot syntax to do the job…
Yes… You sure can use F5 syntax to do it too…

Unfortunately I’m not sure what I’m doing… Can you be more specific?

-P.

What I was saying is…

This script put directly into the button instance

on (press)
{
	loadText = new loadVars();
	loadText.load("lamplight.txt");
	//creating the loadVarsText function
	loadText.onLoad = function()
	{
		scroller.text = this.lamplighttext;
	};
}

and this script put in the frame

yourButtonInstance.onPress = function ()
{
	loadText = new loadVars();
	loadText.load("lamplight.txt");
	//creating the loadVarsText function
	loadText.onLoad = function()
	{
		scroller.text = this.lamplighttext;
	};
}

works the same way… First one is done in F5 format, and the second one is done in FMX format… Know what I mean now???

That could not have been any clearer! Everything is working now… Thanks a lot! :slight_smile:

-P.

No problem… :wink: