LoadVars problem - With a lemony twist

Alright, I’m creating a site for a local band. I’ve decided to create a system where he (the webmaster - also lead guitarist) has the site, and a bunch of .txt files that will load into them. By having the txt files set as a bunch of html code, he can format it as he wishes and get colours and italics and what not.
Well, for the news section, instead of loading one MASSIVE file, of all the bands doings, it will be one text file per entry with two variables, one for the news, one for the date.
each .txt file has a numbered name, 1 being the first 10 (for example) the most recent. I have another txt file that has the number of entries. Simply, the thing loads the file, and then takes the top number as the most recent, genius huh?

well, kinda. I’m having a bit of trouble with the strings. What the hell am I doing wrong? I’m sure its a simple answer.

loadtotal = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	loadText = new LoadVars();
	loadText.load((loadtotal add ".txt"));  //--this is the trouble area I am sure.
	loadText.onLoad = function() {
		one.text = this.news;
		two.text = this.updates;
	};
};

Whats the format of your total-number.txt file?

why are you declaring a new load vars within the onLoad event… im confused :slight_smile:

Jubba: well, currently its just txt. If I put it in HTML 1.0, and turn on render as HTML on the text box, then it should display as html

Ahmed: I did that because I used kirupa’s tutorial and realised that this new loadvars is only to be executed AFTER the thing has loaded. but do you think it might be the cause of the problem?

I mean how is it set up. like

num=10

whats the variable name…

well, it goes as follows:

Total number of entries variable name: total

entry content: news
date: update

I will change them though for the sake of the band so its: content and date

ARGH! forget it. Here is the .fla, can you tell now what I am doing wrong?

I see on the 5th line you are loading a file.
[AS]loadText.load(loadtotal add “.txt”);[/AS]

but loadtotal is a loadVars object.

Is a variable that you are loading from original file to be used to load the second file?

Here

Thanks claudio! well, it loaded the file, which is good, I got it to do that.

I’ll reword my problem:

Ok, first off, I load a variable containing the total number of posts:

loadtotal = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	three.text = this.total;
	total = this.total;
};

This works. No problems there. Next, I want to load the most recent item of news (which is the text file with the highest number as it’s file name) so, that would be someting like this:

loadtotal = new LoadVars();
loadstuff = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	three.text = this.total;
	total = this.total;
	loadstuff.load(total add ".txt");
	loadtotal.onLoad = function() {
		one.text = this.content;
		two.text = this.date;
	};
};

This on the other hand, does not work. It will load the total number, but not the content. What am I doing wrong?

[edit]never mind! i got it to work! there was a typo in the script because I copied and pasted. the proper script goes as such:

loadtotal = new LoadVars();
loadstuff = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	three.text = this.total;
	total = this.total;
	loadstuff.load(total add ".txt");
	loadstuff.onLoad = function() {
		one.text = this.content;
		two.text = this.date;
	};
};

Thanks to everyone who helped![/edit]

np :thumb: