MX loading external .txt files

Hey guys.

Ive got a prob.

When I click on a button eg news, I use the loadmovie function to load news.swf. In news.swf, I have the following command (from Kirupa scrolling dynamically loaded text tut) to load a text file in:

stop();
loadText = new loadVars();
loadText.load(“news.txt”);
//creating the loadVarsText function
loadText.onLoad = function() {
scroller.text = this.newstext;
};

This works FINE locally (on my HD0, but when I upload, the text isn’t loaded!!

I’ve tried using absolute location - (“http://www.decyfa.netfirms.com/news.txt”) but that doesn’t work either! Ne ideas??

I’m not 100% sure, but I think the problem is that on your HDD, the file loads up really fast (it’s loaded even before the onLoad function is declared). I think if you put the onLoad definition in a frame loop and have the loop stop when the file is loaded, then it will work on the server. Something like this:

Frame 1:


loadText = new loadVars();
loadText.load("news.txt");
//creating the loadVarsText function

Frame 2:


loadText.onLoad = function() {
scroller.text = this.newstext;
};

Frame 3:


gotoAndPlay(2);

Like I said I’m not 100% sure about this but it’s worth a shot. And I know it’s not a very elegant solution. :slight_smile:

-Al

Ok - thanx mate! im just gonna try it and see wot happens…C:-)

Thnx… but it stil duznt seem to be wrking. I tried anutha method found on Macromedia’s site, which again wrkd fine locally, but didnt when I uploaded. Nemore suggestions?

Can u post your FLA and TXT files?

Ok - here goez!!

Sorry -I’ve never attached before!

I’ll upload them to my server…

www.decyfa.netfirms.com/My-files.zip

Right click and save As…!

Strange…all I see are stop(); actions…nothing more. Any idea why?

Oh sorrry!!! Ok, when u open home.fla, u hav three layers right? (actions, content, bg).

On the content layer, double click the movie clip (the fisrts frame is “empty” so on the stage all u will see is a white circle). Once u are in that movieclip (called boxDrop),the actions are at the end of the timeline on the actions layer.

Thnx!

Ok thnx! R u going to send it bak via email?

Ok…I haven’t tried this on a server (I don’t have one), but I think it should work. I just editted the actions layer in that MC that sits on the root content layer.

-Al

::EDIT:: darn, can’t attach it…too big. ok, here’s the AS:

In frame 26:


loadVarsText = new loadVars();
loadVarsText.onLoad = function(success) {
	if (success) {
		trace("done loading");
		scroller.text = this.hometext;
	} else {
		trace("not loaded");
	}
};

and in Frame 27:


loadVarsText.load("home.txt");
stop();

Hope it worx.

I am SO stumped… IT’s STILL NOT WORKING!!! Thnx for trying, but it still doesnt want to load the text file!!! Check it out at www.decyfa.netfirms.com to see wot I mean!

:q: :frowning:

Hmm…I have no clue why it isn’t working…sorry. I’ll see if I can figure it out, though. And I’ll let you know.

Ok my last suggestion:

instead of:
trace(“not loaded”);

try:
scroller.text= “not loaded”;

That way you will see if the onLoad method is even running properly. Also, I uploaded it to my hosting (i just set it up) and it works fine…

-Al

Sorry - just got ur reply!

SO my code on frame 26 should look like the following:

loadVarsText = new loadVars();
loadVarsText.onLoad = function(success) {
if (success) {
trace(“done loading”);
scroller.text = this.hometext;
} else {
scroller.text= “not loaded”;
}
};

I’ve sussed it… but I am SUCH A HALF-WIT!!!

I WAS UPLOAIDNG TO A FREE SERVER, ADN I HAD A SUDDEN IDEA WHEN U SED THAT IT WORKED FINE ON UR SERVER, THAT IT WAS MY SERVER!!!:crazy: :crazy: :crazy:

Ur code worked FINE when I uploaded to my host, its just that I was uploading to a server which doesnt seemt o support it - probably because its free!!!

Thanx again mate!!!

LOL!

I hate it when it’s such a simple thing. :slight_smile:

-Al