Need some suggestions about sending variables to CGI
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Need some suggestions about sending variables to CGI

  1. #1
    Junior Member
    Join Date
    Mar 2000
    Posts
    2

    Question

    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,

    David

  2. #2
    Member
    Join Date
    Mar 2000
    Posts
    91

    Post

    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.

  3. #3
    Junior Member
    Join Date
    Mar 2000
    Posts
    2

    Post

    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.

    *sigh*
    datter

  4. #4
    Senior Member
    Join Date
    Feb 2000
    Posts
    195

    Lightbulb

    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>

  5. #5
    Senior Member
    Join Date
    Mar 2000
    Posts
    289

    Cool

    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.
    http://www.k2w.f2s.com

    Unfortunately, the server is down right now, so I may not get it posted until tomorrow night...so check back.
    Kaptain

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com