PDA

View Full Version : loadVariablesNum to LoadVars



waffe
February 8th, 2003, 07:55 PM
When I was working with a txt file locally I used this command

file = new LoadVars();
fileURL = "PhoneBook.txt";
file.load(fileURL);

But now I am posting this file to a server so the code changes to

file = new LoadVars();
fileURL = ("PhoneBook.php?Ran="+random(999), 0);
fileURL = "PhoneBook.txt";

This does not work; flash does not see the txt file.

Flash does see the file online when I use
loadVariablesNum ("PhoneBook.txt?Ran="+random(999), 0);

But I would rather use LoadVars.

Any suggestions.

lostinbeta
February 8th, 2003, 10:26 PM
Why do you have 2 fileURL variables doing two different things?

waffe
February 8th, 2003, 10:56 PM
Funny you ask. This code is from h88. It comes from a project I did a few months back and h88 helped me with it. In fact you did too, but not with this part.

If I take out any part of this code my project will not work. So I believe I have to have file.load(fileURL). This is what you load into loadVares. What you put into loadVars is the file(URL), which is the TEXT file.

So, I do not believe they are doing two differnt things.



:geek:

lostinbeta
February 8th, 2003, 11:02 PM
file = new LoadVars();
fileURL = ("PhoneBook.php?Ran="+random(999), 0);
fileURL = "PhoneBook.txt";


Ok, well that looks a bit off to me. As I believe I stated before to you, I am not good with server-side Flash.. but I will give it a shot..

Try this..

fileURL = "PhoneBook.php?Ran="+random(999);
file = new LoadVars();
file.onLoad = function(success) {
if (success) {
//do this
} else {
trace("File Load Failed");
}
};
file.load(fileURL);

waffe
February 9th, 2003, 06:44 PM
I must of been doing something else wrong because I got it to work. The code;

file = new LoadVars();
fileURL = ("PhoneBook.php?Ran="+random(999), 0);
fileURL = "PhoneBook.txt";

works just fine, thanks for your time.

:blush:

lostinbeta
February 9th, 2003, 06:48 PM
Congrats on getting it to work :)

h88
February 11th, 2003, 09:53 AM
??????????????????????

I can't believe that this code is what your using to post to the php file!!!!!


file = new LoadVars();
fileURL = ("PhoneBook.php?Ran="+random(999), 0);
fileURL = "PhoneBook.txt";

Looks weired tho. Anyways, when you try to post to a file through flash, you should use 'send'!


myLoadVars = new LoadVars();
myLoadVars.send("PhoneBook.php?Ran="+new Date().getTime(), 0, "POST");

Notice that using '0' as the target WILL only post _root variables.

waffe
February 11th, 2003, 07:25 PM
You are right h88 that is not the right code. It should look like this:

file = new LoadVars();
fileURL = "PhoneBook.txt";
file.load(fileURL);

Don't know how I messed that up; you can see in my first post I have it written correctly.


And thanks for the "send" info, I will try it out.