A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Posting variables with PHP to a frame set

  1. #1
    Junior Member
    Join Date
    May 2003
    Posts
    15

    Posting variables with PHP to a frame set

    I'm trying to get my game variables to save to a php script - but I want the script to open to a hidden frame window. For some reason it wont open it to that frame with IE, and with Netscape its not transferrring all the variables over. I've been stuck on this for months, so if anyone can help me, Id REALLY appreciate it!
    www.FreeFlashRPG.com/Angels/AngelGameDemo.html

  2. #2
    Senior Member random10122's Avatar
    Join Date
    Mar 2002
    Location
    Sheffield, UK
    Posts
    1,747
    Could be a netscape bug, have you tried with IE?

    This is the wrong place for this question IMO, it has nothing to do with games. Not even to do with flash by the sounds, try a php forum.

    www.php.org

    fracture2 - the sequel
    fracture - retro shooter
    blog - games, design and the rest

    "2D is a format, not a limitation" -Luis Barriga

  3. #3
    Junior Member
    Join Date
    May 2003
    Posts
    15
    my PHP script is fine.
    I just wanted to see if some1 designed a dynamic game like mine in which you call the script without disturbing the current frame window, ie, the Flash game.
    I don't want it to open in a new window because if it gets closed, the script wont work.
    And I have tried it with IE, and like I said, it opens the script to the movie frame instead of the frame window:
    Heres the getURL Flash actionscript. It reads:
    getURL("http://www.freeflashrpg.com/Angels/write_cFile.php","save_window",
    "POST");
    where "save_window" is the name of the hidden frameset window.
    But it loads it to the main window instead, I even tried using javascript:window.open() and got it to the right frame but then all the variables didnt post. Can some1 please help?







  4. #4
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    You could also try Scripting & Backend forum.
    http://www.flashkit.com/board/forumd....php?forumid=4

  5. #5
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Or you could use an iframe..

    Code:
    getURL("javascript:loadwindow('http://www.freeflashrpg.com/Angels/write_cFile.php?var1=value1&var2=value2')");
    And in the html:

    Code:
    //in the HEAD:
    <script>
    function loadwindow(theURL){
    	iframe.location = theURL;
    }
    </script>
    
    //somewhere on the page:
    <IFRAME name="iframe" src="" width="1" height="1"  scrolling=no border=no frameborder="0" marginwidth="0" marginheight="0" vspace="0"  hspace="0">You'll need IE3.0+, N5+ or Opera4 to see this.</IFRAME>
    Make a mental note that a javascript does NOT send flash GET and POST variables with it to the frame.

    Jeroen

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

  6. #6
    Dont you normally just use a loadvars or loadvariable with the things you want to send specified on the end of the url (get)?

    Code:
    on(release) {
    	loadVariables("coolguy.php?username=McNugget&password=whatahunk", "_root.loadTarget");
    }
    *Note for the example I used loadVariables, however I would strongly sugges using the loadVars object.

    Nugget

    *edit* Bah now that I read your subject you specified you wanted to use Post... um heres how you can use get

  7. #7
    Here is what I think your looking for, and there is no need to use frames. You would use the loadVars object, and then use the sendandload so the page isnt redirected.

    Starting Page
    http://www.devshed.com/Client_Side/F...rms/page1.html
    Page that I think your looking for
    http://www.devshed.com/Client_Side/F...rms/page6.html

    Nugget

  8. #8
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    McNugget.. you're right of course. I usually use the loadvars/POST manner.

    He asked for a getURL version, and he got it. ^_^

    macbird, in reply to your email/pm:
    in the code after ....save_window.php?cFile=cFile'
    it transfers cFiles value as 'cFile'
    The text before the '=' is the variable name, and the text after the '=' is the value of that variable. Hope that that clarifies it a bit.

    So a file adressed as in your example, "save_window.php?cFile=something"

    The cFile variable can be called in PHP by '$cFile'.

    Outputting the cFile variable on screen would be with the code: echo $cFile;

    Hope that helps.

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

  9. #9
    Junior Member
    Join Date
    May 2003
    Posts
    15
    Thanks Jeroen, I appreciate this and I know what your saying, but..
    When the script loads in the iFrame,
    and I echo the variables $cFIle and $Account I get:
    'cFile' and 'Account'
    instead of the values their suppose to have. I don't know why its doing this...
    heres my code one more time:
    Code:
    getURL("javascript:loadwindow('http://www.freeflashrpg.com/Angels/write_cFile.php?cFile=cFile&Account=Account')","");
    I traced the variables in the movie right before sending them, so I know they have the right value..

  10. #10
    Senior Member random10122's Avatar
    Join Date
    Mar 2002
    Location
    Sheffield, UK
    Posts
    1,747
    Code:
    getURL("javascript:loadwindow('http://www.freeflashrpg.com/Angels/write_cFile.php?cFile="+cFile+"&Account="+Account+"')","");

    fracture2 - the sequel
    fracture - retro shooter
    blog - games, design and the rest

    "2D is a format, not a limitation" -Luis Barriga

  11. #11
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Well.. random answered that question. And here's a response on how to use loadvars as requested in your mail.

    ActionScript:
    loadVariablesNum("script.php", 0, "POST");

    This loads AND sends all variables on the _root of the flash movie.
    For example, in the _root might be 2 variables.
    flashVar1 = 3;
    and
    flashVar2 = 6;

    Now, use a button with that AS attached. The PHP file could for example be like this:
    Code:
    <?php
    	$phpVar1 = $flashVar1 * $flashVar2;
    	echo "&phpVar1=$phpVar1";
    ?>
    Now, flash loads the string "&phpVar1=$phpVar1" into the _root. The flashplayer converts that string to variables and values. So if you would have a textfield on the root with 'phpVar1' as its variable, it would display '18'.(without the quotes)

    Hope that helps.

    Jeroen

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

  12. #12
    Junior Member
    Join Date
    May 2003
    Posts
    15

    it works!

    36 hours and a bottle of Jack later, I just wanted to thank every1 that helped me get my game working. I ended up not using frames at all and just went with the loadVars command.
    Code:
    	loadVariables("http://www.freeflashrpg.com/Angels/write_cFile.php?Account=Account&cFile=cFile","","POST");
    Still needs some tweaking, but overall it works!
    Thank you McNugget, Jeroen, and Random! If you like I can hook you up with an account to either of my games.
    Hit me up, peace!


  13. #13
    Flash Developer on a break
    Join Date
    Jun 2001
    Location
    The Netherlands
    Posts
    1,370
    Hehe.. no problem.

    And you can always email me for stuff.

    | "Keep Flashing!"-Jeroen
    PHP multiplayer? Check this thread: PHPgateway

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