Actionscript 2 & PHP Data Transfer

In the below example we will use Actionscript 2 to call a remote PHP file that will return data to it.
It is a simple way of transferring data between the server and client.

Actionscript 2 Code:

callRemoteFile = function(ourVariable:String) {
        var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
                if (success) {
                        if (result_lv.message=="success")
                                trace("done! "+result_lv.returnValue);
                        else
                                trace(result_lv.message);
                } else {
                        trace("Error connecting to server");
                        return false;
                }
    };
    var send_lv:LoadVars = new LoadVars();
    send_lv.ourVariable = ourVariable;
    send_lv.sendAndLoad("http://www.andrewodendaal.com/example/file.php", result_lv, "POST");
}
callRemoteFile("some text here");

PHP Code:

<?php
        if (isset($_POST)) echo "a=1&message=success&returnValue=".$_POST["ourVariable"]."&b=2";
        else echo "a=0&message=failed&returnValue=nothing&b=1";
?>

Share This Article

Related Posts

Comments

There are no comments on this entry.

Trackbacks

There are no trackbacks on this entry.

Add a Comment

Required

Required

Optional

Latest Domains

1. weebly.com
(1 day ago)
2. whpromotions.co.uk
(1 day ago)
3. adsl24.co.uk
(1 day ago)
4. youryoungmodels.net
(1 day ago)
5. enom.com
(1 day ago)
6. dynect.net
(1 day ago)
7. websitewelcome.com
(1 day ago)
8. hostgator.com
(1 day ago)
9. uploading.com
(2 days ago)
10. soccernetghana.com
(2 days ago)

Services

PHP MySQL Apache Flash Air Java C++ Python