External Text into Dynamic text box

Hey everyone,
So i guess this is a simple thing and i just cant figure out for the life of me why it wont work, any help would be great!

This is the code in the first frame of my actions layer:

myData = new LoadVars();
myData.onLoad = function() {
news_txt.text = this.newsHome;
};

myData.load(“content.txt”);

stop();

This is what my text file looks like:

newsHome=Your text goes here.

thanks in advance!

Hrm try this. Also make sure that your characters are embedded, and that the textbox isn’t set to bold. Check your instance names as well.

    myData = new LoadVars();
    myData .onLoad = function() {
         news_txt.text = myData.newsHome;
    };
    myData .load("content.txt");

shouldn’t it read


&newsHome=Your text goes here.

yes i should

Thanks, ill take a shot when i get in front of the computer!

Ok so i tried everyones suggestions, not so sure why its not working, its in the first frame of the mc, also i did not set the variable in the properties window since the AS sets it…this is pretty embarrasing!

Any help would be great!

myData = new LoadVars();
myData.onLoad = function() {
news_txt.text = this.newsHome;
};

myData.load(“content.txt”);

Be sure you have named the textfield to newcs_txt .
be sure that content.txt reads
&newsHome=Eymanyourcrazy

Ok, so i tried it outside of the site file and it works! But once i go into the MC on the main website with the same exact code it doesn’t? Could something be interacting with the AS to make it not function correctly?

Any help would be greatly appreciated, this is a big thorn in my side!

xml ■■■■ you!

what?

.xml instead of .txt?

If it works locally but not remotely, that suggests one of two problems. The most obvious problem is an incorrect path to your txt file…is it in the same directory as the SWF? Have you tried entering the absolute path to the txt file in your code, rather than using a relative path? Secondly, check the spelling of the txt filename on the remote server…you’d be surprised how many people try to capitalise their filenames and then wonder why it won’t work.

The second problem is one of security. Flash should allow you to load variables providing that the SWF and the file containing the variables are in the same domain. I’m guessing that they probably are so this problem can most likely be ignored.

Finally, it might also be worth changing your code slightly to indicate that there’s a problem loading the data:


myData = new LoadVars();
    myData .onLoad = function(success:Boolean) {
        if (success) {
         news_txt.text = myData.newsHome;
        } else {
         news_txt.text = "Error connecting to server";
    };
    myData .load("content.txt");

There’s also no need to use an ampersand in your textfile unless you’re loading more than one name-data variable pair.