Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic text

Status
Not open for further replies.

Charliesz

Technical User
Jul 24, 2003
95
0
0
CA
Hello.

I would like to have text box(movieclip) to update itself with different text content upon button click(i have afew buttons in a different movieclip)
Text is being retrieved from a text file. i have couple of text files with different content in them.

My current text box ActionScript looks as such:

myData = new LoadVars();
myData.onLoad = function(){
dyntext.htmlText = this.content;
};
myData.load(company.txt);

stop();



To acomplish the above question i decided to go with a global variable that will substitute file (txt) name so itll become :

...
myData.load(testtxt);

On my buttons ActionScript i set the following:

on (press) {
testtext='services.txt';
}


Unfortunately , nothing is happening when the button is clicked. What am i doing wrong?

Thanks
 
When you press your button, your variable is changing fine, but its not loading any text

That's because you have to initiate the myData.load(testtxt); command again after you changed your variable.

Make your button do this instead

Code:
on (press) {
    testtext='services.txt';
    myData.load(testtxt);
}


if you'll notice, you also changed variables from testtext to testtxt

you could just remove the variable and say this:

Code:
on (press) {
    myData.load(services.txt);
}

i think that might work, try it out
 
Thank you.The above partially worked. I also had to tell my text box to refresh itself with the new loaded content.

So my code on the button looks as such:

on (release) {
myData = new LoadVars();
myData.onLoad = function(){
_root.servicemain.servicemaintext.dyntext.htmlText = this.content;
};
myData.load('services.txt');

}

it might be dirty but it works :)

Thanks alot for your help
 
well do you have to put all of those actions on that button?

try this:

Code:
//put this on actions keyframe:
myData = new LoadVars();
myData.onLoad = function() {
	_root.servicemain.servicemaintext.dyntext.htmlText = this.content;
};

//put this for button actions:
on (release) {
	myData.load('services.txt');
}

you dont have to create a new loadVars and define an onLoad function more than once. Once they are defined, they can be used over again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top