A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: PHP sending SOME variables to flash, but not sending others!

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    4

    PHP sending SOME variables to flash, but not sending others!

    Hi, I'm using flash 8. Basically this is what I am trying to make:

    Two people will communicate with eachother using a sound board. There are a bunch of buttons on the flash interface, each connected to one word. One person will click on various buttons/words to form a sentence. He/she will click "send" and it shall send the sentence over, but in audio form. Each and every word was pre-recorded and I've coded it so that each word/sound file is played out one before the other to create an audible sentence for the other person.

    Now, how I decided to go about this is to send the data to PHP, and have PHP send it back to flash (to the other person) so that he or she may hear the sentence. I am not sending audio here, though, but merely a few variables. "word01" is the first word, "word02" is the second word. Then, the receiver's applet will get a "if word01 = "hello" then play hello_sound" etc.

    Now the problem is that flash cannot grab the variables from PHP. It can grab SOME, but not all. Let me post my script first then I will explain a bit more.


    Flash script:

    Code:
    stop();
    
    var word_11_r:String = "ONE";
    var word_12_r:String = "TWO";
    
    getURL("chat2.php", "newWindow", "POST");
    
    myVars = new LoadVars();
    myVars.load("chat2.php");
    
    
    myVars.onLoad = function() {
    
    	sentenceBox.text = ("Word#1 is "+myVars.word01+" and the Word02 is "+myVars.word01+". Word00 is "+myVars.word00+".");
    };
    PHP script:

    Code:
    <?php 
    
    $word01 = $_POST['word_11_r'];
    $word02 = $_POST['word_12_r'];
    
    $word00="HelloWorld";
    
    $vars = "" ;
    $vars .= "word01=" . $word01 . "&" ;
    $vars .= "word02=" . $word02 . "&" ;
    $vars .= "word00=" . $word00 . "" ;
    echo $vars ;
    
    ?>
    Now then, in this code I am trying to get flash to return word01 and word02 back, but it comes out as: "Word#1 is undefined and the Word02 is undefined. Word00 is HelloWorld."

    Notice that "HelloWorld" (which is from the variable word00) displays in flash, so seemingly it is not a coding problem of Flash, as I AM getting the code from PHP and putting it into flash. Seemingly, it appears to be that I am not sending variables FROM flash to PHP properly. HOWEVER, when I echo that above statement in PHP, it shows me that PHP has gotten the vars from flash -- says this: "word01=ONE&word02=TWO&word00=HelloWorld"

    So basically, everything is smoothly translating into PHP, but it cannot be translated back into flash for some odd reason, but the myVars coding is seemingly right because it was able to translate SOME variable from PHP to flash, just not the ones that were translated FROM flash originally (which, again, was done correctly). Do you see the illogicality of this concept? Both parts seem to be working but nothing is. Bah, I've spent so many hours trying to get it to work that I'm just about to pop. I'm sorry, but if you have ANY info that might help me please, I would REALLY appreciate it.

    Thanks again

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    you are sending
    word01=ONE&word02=TWO&word00=Hello
    it might help to send
    &word01=ONE&word02=TWO&word00=Hello&

    Musicman

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    4
    Still doesn't work =(

    Any other ideas?

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    if this is on a public server, and the swf is version 7 or less, I could perhaps do some tests on it and see whether something looks suspicious.
    Please show url to actual website, not to a fla file.

    Musicman

  5. #5
    Junior Member
    Join Date
    Dec 2007
    Posts
    4

  6. #6
    Junior Member
    Join Date
    Dec 2007
    Posts
    4
    I changed a bit of the PHP code btw, but the gist is still the same. I give word_zero a value within the PHP code itself, and it plays back into flash smoothly. For word_one and word_two, their respective values are ONE and TWO, which flew in from flash into PHP. PHP recognizes it and outputs it correctly, as it does with word_zero, however only word_zero makes it back to flash.. and within flash, I use the same code to output all three of them.

  7. #7
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    this makes two calls to chat2.php - on one it just loads data and gets the empty word01 ... this is the loadvars one
    On the other one, it posts data ... and gets a different result
    It seems that sending data works fine, but is not the right approach for your task at hand.
    If I understood you right, there are two people using the web page at the same time ... or possibly several pairs of two people. The two people in a pair would use different computers. This essentially means that you cannot really "send back" to the other person - rather A would send data to the server which gets saved there, and B would poll the server every x seconds until there is new data

    Musicman

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