A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: problem sending vars from flash to php

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    4

    problem sending vars from flash to php

    having an unusual problem sending vars to php. it is sending the var but my flash game is being unloaded off the site once the var is sent.

    if there is another way to send VARS please let me know, OR maybe my code is wrong. any suggestions will be greatly appreciated



    Code:
    function sender()
    {
    	varsToSend = new LoadVars();
    	varsToSend.var1 = beatTimer;
    	varsToSend.var2 = enemyScore;
    	varsToSend.var3 = playerScore;
    	varsToSend.var4 = beatTimer;
    	varsToSend.var5 = flawless;
    	varsToSend.var6 = comeBack;
    	varsToSend.send("http://code.com/gamefiles/gg_test.php","_self","POST")
    		trace(varsToSend);
    }

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I've never actually used LoadVars, but I tested your code and it opens a new window from Flash, and since you're window parameter is set to _self, the window will be replaced with your current one, which I think is why your movie gets unloaded. However, I think you rather should use this code to send variables:

    Actionscript Code:
    loadVariablesNum("myfile.php", 0, "POST");

    Then, in your PHP file, type something similar to this:

    Actionscript Code:
    $var1 = $_POST['beatTimer'];
    $var2 = $_POST['enemyScore'];
    $var3 = $_POST['playerScore'];
    $var4 = $_POST['beatTimer'];
    $var5 = $_POST['flawless'];
    $var6 = $_POST['comeBack'];

    and if I'm not mistaken, those PHP variables should hold the information sent from Flash. I've only tried loadVariablesNum with dynamic text variables, but not with normal variables, but I'm pretty sure it'll work!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Tags for this Thread

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