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");
Code language: JavaScript (javascript)

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";
Code language: HTML, XML (xml)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments