Software Engineering

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("Error connecting to server");
return false;
var send_lv:LoadVars = new LoadVars();
send_lv.ourVariable = ourVariable;
send_lv.sendAndLoad("", result_lv, "POST");
callRemoteFile("some text here");

PHP Code:

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