Loading external .txt into Flash

I have been trying to get text to load into Flash from a .txt file. Right now I have a dynamic text box set up with an instance name and I am using this code:
homeContent = new LoadVars();
homeContent.onLoad = function () {
homeContent_txt.text = this.content;
homeContent_txt.multiline = true;
homeContent_txt.wordWrap = true;
homeContent_txt.autoSize = “center”;//or “left”, or “right”, or true
};
homeContent.load(“home.txt”);

stop ();

But when I load the page the word “undefined” shows up inside the text box. Not the actual text from the .txt file. But that is the only thing I get. No error or anything else. Does anyone have any idea what could cause this.
:pa:

This works fine for me; Are you sure the syntax inside your home.txt is as follows: content=this is the content
?

:slight_smile: if yes, post FLA example

Yeah. It isn’t working at all. Here is the .fla. Do I not have the .txt file in the right place? I have it in the same directory as the .fla.

Here is the whole folder zipped.

Fixed. Look closely what i ment…

content=hat is it that shapes life out.............

:slight_smile: to that variable, named “content”, you are assigning the content of your txt file, directly inside the file. Then inside Flash, you load the whole file, flash automatically executes the command content=[content string whatever it is] and puts that String - content of your file - into variable named “content”. Now you can work with it inside flash.

Okey, one more suggestion: some letters in your .txt file are parsed incorrectly by flash, save your .txt file with UNICODE encoding (or UTF-8 or whatever which supports those letters, not ANSI). You can do so this way: open your .txt in Notepad, choose Save As… and in “Encoding” combobox, choose “UNICODE”. Save, Replace File, and you’re good to go.

:slight_smile: nJoy

Oh! I didn’t realize that you needed that code in the text file. Thanks so much for your help. It is working perfectly now. I’ll just keep working now with my dunce cap on.C:-) Thanks for your help.

Glad to see a happy face :slight_smile:

enjoy the process!