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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy way to load .txt files into dynamic text boxes

Status
Not open for further replies.

Kirderf

Technical User
Oct 4, 2000
183
US
I have read many of the threads and viewed the tutorials(macromedia) on this, but still cannot make this work. I am just trying to make a text box that I can fill with text from a separate text file. Is there an easier code than what I have copied below?

text file is called
test.txt

var1=blablabla (i have tried &var1=blabla and "&var1=blabla" and &var1=blabla&)

FlashFile-mx04
dynamic textbox instance named "scroller"

in the timeline actions i placed the following code:

loadVarsText = new loadVars();
loadVarsText.load("test.txt");
//assign a function which fires when the data is loaded:
loadVarsText.onLoad = function(success) {
if (success) {
trace("done loading");
//Now that we know the data is loaded,
//set the text content of the Text Field
//with the instance name "scroller" equal to the
//contents of the variable
scroller.text = this.var1;
} else {
trace("not loaded");
}
};


There it is.
By the way, is the scrollbar component missing in MX2004?
I don't have it in my version.

I'd gladly pay you on Thursday
for a hamburger today!
 
What does thr trace say? Loaded or not?

Text file should start off with...

var1=blablabla or &var1=blablabla or &var1=blablabla&, but not with double quotes.

Other thing to check... Hope you haven't set the Variable box in the textfield's properties. It must remain CLEAR! Since LoadVars() uses scroller.text, and NOT the variable set in the VAR box.

Regards,

cubalibre2.gif
 
Okay, now I see the problem. I am using MX 2004 and the flash player was set to 7 instead of 6 and Actionscript 2 instead of 1.

I changed to Player 6 and Actionscript 1 and it works.

Thanks for the great posts.

I'd gladly pay you on Thursday
for a hamburger today!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top