For loop variables/arrays

yep, it would be useful :slight_smile:



//read the text file "legends.txt"
myvars=new loadVars();
myvars.load("legends.txt");
//when the text file fully loads, perform some actions
myvars.onLoad=function(){
	_root.statbox.text="loaded"; //just say loaded at top right of screen
//establish new arrays (lotinfo) that are the loaded variables split into arrays;

	for(i=1;i<5;i++){
	
		myref=this["lot"+i];//reference to the variable lot plus the value of i
		trace(myref);
		lotinfo1=myref.split(","); /*KIRUPA HELPERS! This is where instead of lotinfo1,
		I would like it to give me lotinfo1, lotinfo2, lotinfo3, etc.. (as it goes through
		the values of i).
		*/
			
				}
}

the legends.txt file simply reads lot1=sold,pic1.jpg&lot2=available,pic2.jpg&lot3=pending,pic3.jpg

so and so forth.

I hope this helps clarify.

Thanks a million.

bump…since it is pending

I lost what u need when i saw that code!

lot1="sold,pic1.jpg";
lot2="available,pic2.jpg";
lot3="pending,pic3.jpg";
for(var i=1;i<4;i++){
	myref=this["lot"+i];//reference to the variable lot plus the value of i
	trace(myref);
	_root["lotinfo"+i]=myref.split(",");
}

This seems to do the job.

pom :slight_smile:

could u explain ur code ilyas, or something wrong with me today! :sleep:

Well, there’s not much to explain, h88. Since the text is loaded, I just declared the strings that are loaded, and then 3 arrays (created by the split) are created on the _root.

Or am I off course?

thats it, i got it!

That’s the ticket, Pom. I don’t know what happened, but I tried that way in one of my attempts, and it did not work. That is really, really weird. Anyway, that certainly gets me back on track. Thanks!

as a matter of fact, I checked one of the earlier versions and it says exactly that, when I ran it, still gave me assignment error. I cut the text, pasted it again, and it worked! How is that for fun?