A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: sending value from flash as2 to php script

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    sending value from flash as2 to php script

    Hi,

    I have posted before about the same issue but very probably not in the right way. I think I was running a old php version when those files worked for me and now I have read that the syntax has changed an so on...

    All I want to do is try to understand php loading variables from flash from scratch.

    I am basing on this tutorial example file where you send and receive only one variable.

    the code in flash is as follows:

    Code:
    var myload:LoadVars = new LoadVars();
    button.onRelease = function():Void 
    {
    	myload.myans = myans_txt.text;
    	myload.onLoad = function(checkAnswer:Boolean)
    	{
    		if (checkAnswer)
    		{
    			news.text = myload.ans;
    		}
    	};
    	myload.sendAndLoad("http://localhost/test.php",myload,"POST");
    };
    in the php side:

    PHP Code:
    <?phpif($_POST[string]){
        $upper = strtoupper($_POST[string]);
        echo "result=You just wrote $upper";
    }
    else{
        echo "result=You did not write anything";    
    }
     
    ?>
    this worked before I installed the newest version of WAMP with php 5.4.12. Is it deprecated perhaps? I would appreciate any help on beginning php. Not that I haven't googled, but I haven't been able to find a very simple updated example of sending variables in AS2

    thanks

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap,

    not sure what you're asking here really, but it has nothing to do with wamp, php file
    PHP Code:
    <?php

        $upper 
    strtoupper($_POST['PartA']);
        
        if(
    $upper)
        {
            echo 
    "&answer=You just wrote ".$upper;
        }
        else
        {
            echo 
    "&answer=You did not write anything";
        }
        
    ?>
    and flash file
    PHP Code:
    // *** Send Data
    function SubmitData()
    {
        
    trace("Sending");

        var 
    OutData = new LoadVars();
        
    OutData.PartA news.text;
        
        var 
    InData = new LoadVars();
        
    InData.onLoad DataReturned;

        
    OutData.sendAndLoad("http://localhost/test.php",InData,"POST");
    }
    // *** Received data
    function DataReturned()
    {
        
    trace("Received");
        
    news.text this.answer;
    }
    // *** Button press
    button.onPress = function()
    {
        
    SubmitData();
    }; 

  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    Thanks, FruitBeard,

    I was very confused (as usual)... I was merging two different tutorials in one without noticing...

    One with text and another one with a simple mathematical quiz. This one seemed to be old, I just made it work adding the php tag it was missing.

    All I want is to start from scratch and see if I can send email without the phpmailer I'm using. I think I should; I was only using it thinking I was sending email through smartfox's emailer system.

    Thanks again,

    see you

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