PDA

View Full Version : detect when txt file is loaded--nothing's working


hwormser
09-19-2003, 12:26 PM
OK, I've read all the tutorials and tried about 10 different approaches and nothing is working.

I'm loading variables from an external txt file and putting those variables into dynamic text boxes. Everything works fine on my computer, but when I upload it to my web server, the text doesn't show up. If I throw in a bunch of frames between the first frame, where I load the text file, and the frame where I'm actually telling the variables to go into the text boxes, then it works. So presumably the issue is that the txt file isn't loading completely before I'm calling for the variables.

So I've tried a bunch of methods to make the movie pause until the txt file has finished loading, but nothing is working. Attached is a sample of what I'm trying. This one looks to see whether the percent loaded < 1, and, if so, loops back to try again:

percentLoaded = myData.getBytesLoaded() / myData.getBytesTotal()
if(percentLoaded < 1){
prevFrame()
} else {
nextFrame()
}

It works fine on my computer, but when I upload it to my web server, no text shows up.

Any help with this would be most appreciated. I'm about ready to shoot myself.

pellepiano
09-19-2003, 04:21 PM
You can not preload a textfile the way you do a movie. A simple way of doing it is to load the textfile into a movieclip as you can use....

onClipEvent(data){
//Anything put here is activated when the variables are all loaded
}


....ON the movieclip, as the action is not executed before all of the textfile is inside the MC ( one could wish that it was possible to do this in the main timeline too ).

To load the textfile is straightforward.

theMC.loadVariables("theTextFile.txt");

hwormser
09-20-2003, 05:09 PM
Thanks, that seems to be working.:)