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,
It seems that you are not actually sending any variables from Flash. Or perhaps the ones you are sending are null.
Are you the sending from within a movie? It so, only variables that are native to that movie will be sent.
Yes the variables come from within the movie. There are a few movies running on various layers though the variables and the call for the CGI are on the same one.
If you don't mind using a GET request..
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.
<EMBED src="/cgi-bin/ubb/Members/sigs/00000205.swf" quality=high WIDTH=500 HEIGHT=50 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> </EMBED>
I just wrote a script to keep a high scores list. It's called ScoreKeeper. It is very customizable and should suit the needs of many Flash game developers.
Unfortunately, the server is down right now, so I may not get it posted until tomorrow night...so check back.
Click Here to Expand Forum to Full Width
Poll by Flashkit.com