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:
content=hat is it that shapes life out.............
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.
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.