I've built a game in Flash that I need to send the high scores out of, to a TXT file on my server.
The score is kept in a variable called SCORE (imagine that) and the name is entered in a text box to the variable NAME.
The CGI, which I had written for me recently takes input like this : http://mw.server.com/cgi-bin/script....=BUD&score=999
where Bud is the players name and 999 is his score. This script will then save these two variables to a high score list, and it works perfectly from a browser. If I enter the above info into the address bar with a name and a score it will save that info the the TXT file with no problem. Doing it from Flash is another story.
I've tried numerous means to get the variables out including using 'load variables into location' with both get and post. I also tried 'get URL' with no luck either. I went so far as to pick apart several guest book FLA's to see how they got variables out to a cgi script with no luck at all.
Any suggestions would be appreciated.
Thanks in advance,
You can control exactly what is sent to the server. Just set your URL to Expresion, and build the URL like this:
Load Variables ("http://www.server.com/cgi-bin/script.cgi?name=" & name & "&score=" & /:score)
That is assuming that the "name" variable is local (in this MC) and the "score" variable is on the main timeline.
Or if you want to use the Send Variables command.. The perhaps you just need to make sure that all the variables you want to send have been copied to this movie clip. For this, you can preceed your Load Variables command with Set Variable commands like this:
Set Variable: "score" = /:score
etc.. for whatever variables you need. That command copies the "score" variable from the main timeline to a variable called "score" inside the current movie clip.
Also.. make sure that you are directing the results of that Load Variables command where you want them. Check your Target attribute for the Load Variables command. That determines where in your Flash movie the variables will stored when they are returned from the server. You can point that to the main timeline: "/" or "_level0". Or you can point it to a movie cilp: "/game/scorecheck".
Does that help?
Funny you should mention this Actually, this is exactly the code that I just wrote last night for a Tetris clone that I am writing in Flash. It also has an online High Score table. I should be releasing it later today.