Load *.txt files to fielda (textbox)?

Probably a stupid question - Way too many coffees today and cannot get this to work… ok…

this is what I dont know how to do… [MX 2004]

When [onrelease] of button 1 I want button1.txt to be displayed within my dynamic text field [box]

the same would go if user hit button 2…

any advice/ideas

thanks kindly:ogre:

gotta use loadVars baby, works like a charm. Check the tutorials.

I’m not sure if I remember it perfectly, but it will go something like this.

getText = new.loadVars();
getText.load("yourFile.txt");

button1.onRelease(yourField.text = getText.txtVar);

Where you text file looks like:

txtVar=This is all of your writting

This question has been answered about 2.3 million times - about .4 million on this site alone.

That didnt work… :frowning:

I’ve tried looking for an MX 2004 tutorial but cannot…

Do you have any off hand? Thanks again - Your efforts are apreciated on this end!

Dino

This works flawlessly for me in MX04:

loadText = new LoadVars();
loadText.load("data.txt");
loadText.onLoad = function() {
name.text = this.name;
email.text = this.email;
location.text = this.location;
};

It’s cut and pasted from the Kirupa tutorial, except the capital “L” on LoadVars().

It should be:


lv = new LoadVars();
lv.load("button1.txt");
lv.onLoad = function(ok){
var ref = this;
if(ok){
button1.onRelease = function(){
textField.text = ref.yourVar
}
} else {
trace("File could not be loaded.");
}
}

Where yourvar is the variable from the textfile:

yourvar=yourvalue&anothervar=anothervalue&…

hehe yup.

By the way V, your footer pic looks like one I took a while back:

http://www.redscreen.net/photolog/archives/000181.html