Preload txt/asp

I use txt to test my work locally, but when I go live it is an asp file.
All that I have read tells me there is no difference between the two as long as they are formatted the same. So, no worry it’s all good.:slight_smile:

cool then, i assume its working right now, wish u all the best :)!

yours,

h88

Does this actually preload the txt file?
How do I out put the messages?

Well, are you getting anything at all from the ASP script?

Yes I am getting data from the asp script. But it is not preloading because I have to hit my reload button which populates the list box. The list box should populate on its own. When the code calls the listbox to populate, the asp file is not loaded yet and does not populate.

*Originally posted by waffe *
**Does this actually preload the txt file?
How do I out put the messages? **

yep, it does, and if u want to output ur message, give the dynamic text field a variable called message and itll work fine

*Originally posted by waffe *
**Yes I am getting data from the asp script. But it is not preloading because I have to hit my reload button which populates the list box. The list box should populate on its own. When the code calls the listbox to populate, the asp file is not loaded yet and does not populate. **

could i have a look at the code uve done =) !

yours,

fileURL = “asp.txt”
file = new LoadVars()
file.onLoad = function (success) {
if (success) {
message.text = myVars_obj.message
} else {
message.text = “Error loading file”
}
}
file.load(fileURL)
myArray = new Array(1);
file.onLoad = loaditems;
function loaditems() {
for (i=0; i<file.NumItems; i++) {
var ID = eval(“file.ID”+i);
var Link = eval(“file.Link”+i);
var Desc = eval(“file.Desc”+i);
myArray* = new Array(2);
myArray*[0] = ID;
myArray*[1] = link;
myArray*[2] = Desc;

	onChange = function () { screen.loadSound(listbox.getSelectedItem().data["Link"], true);};
	
}

}

Then to populat my list box, I have this code in a different layer and frame.

for (i=0; i<myArray.length; i++) {
listbox.addItem(“Read “+(i)+””, DataProvider);
var DataProvider = {ID:myArray*[0], link:myArray*[1], Desc:myArray*[2]};

in line no. 5:

message.text = myVars_obj.message

it should be as refrenced in ur LoadVars Object name:

message.text = file.message

check it out, maybe that was wrong!

Off topic:

h88 - what does your handle stand for?

just curious…

Rev:elderly:

hehe, man, its refered to my first letter of my name and 88 as of my date of birth, sux right :*(

No, not at all…

In SF, there was just a lawsuit to stop Old Navy from selling merch with 88 on it (they said it stood for HH, or Heil Hitler in gang speak)…

Also, it could be interpreted as hates (h+8’s)…

Just curious, asking questions… being an old fart wanting to keep in touch… =)

Rev:elderly:

Not doing it, same problem as above.
Have you looked at the tutorial on actionscript.org.
Because there the files are preloading.
How in your code do the files preload?
I would like to set up a simple “Loading” sign so I can see that the files are preloading.

:slight_smile:

btw, ur code had some problem, in line 14, in the " for" statement!

ill look it up now for u.

yours,

This is my asp file that flash is reading

&ID0=100&Link0=1045_4311.mp3&Desc0=wow&

&ID1=101&Link1=1045_4311.mp3&Desc1=o&

&ID2=102&Link2=soulen.mp3&Desc2=neato&

&ID3=103&Link3=thumpen.mp3&Desc3=great&

&numItems=4&

&EOF=true

numItems tells how many rows there are.

EOF is from actionscript.org. It works with flash like this

if (EOF == “true”) {
gotoAndPlay(4);
} else {
gotoAndPlay(2);
}

Thus, the preloader in flash for the asp file.
But this does not go with loadVars.:-\

hi waffe,

i did that example for u, it would show Loading… while the movie is loading, and onload, it will show the txt content, satisfied?=)

yours,

h88

I do believe I can work with that. The if statement will turn into
if (success){
gotoAndPlay(4);
} else {
gotoAndPlay(2);
}

So it does not populate the list box before its ready…

OOOOO YAAAAAAA:)

You time is well appreciated

Thanks h88

okay, i think that wut u need:

stop(); 
message.text = "Loading...";
fileURL = "asp.txt" ; 
file = new LoadVars(); 
file.onLoad = function (success) { 
     if (success) { 
          message.text = urTargetVariableInAsp.txt
		  myArray = new Array();  
          for (i=0; i<this.NUMITEMS; i++) {  
               var ID = eval("this.ID"+i);  
               var Link = eval("this.Link"+i);  
               var Desc = eval("this.Desc"+i);  
               myArray* = [ID, Link, Desc];   
               var DataProvider = {ID:myArray*[0], link:myArray*[1], Desc:myArray*[2]};   
               listbox.addItem("Read "+(i)+"", DataProvider); 
          } 
          listbox.onChange = function () { 
               screen.loadSound(listbox.getSelectedItem().data["Link"], true); 
          } 
     } else { 
          message.text = "Error loading file"; 
     } 
} 
file.load(fileURL) ;

wish it helps,

yours,

I believe we are done with this thread.

Your code works quite well, I had to change a few things to get it all to mold properly. O, and thanks for fixing up my array, I was getting doubles when I loaded it.

You rule--------h88!!

Kirupa Rocks.:stuck_out_tongue: