Hey guys,
Something weird is happening to me, and I don’t know how to solve this. What’s frustrating me is that In the past this worked just fine for me, and now it doesn’t for some reason.
What I’m trying to do is send some variables from flash to php, and receive some other variables back (ultimately this will be used for getting info from a DB), right now all the PHP file does is return the same value sent to it.
If someone could just go over it for a few seconds and let me know what I’m doing wrong, I’d appreciate it.
here’s the as3 code:
import flash.net.*;
import flash.events.Event;
var urlVars:URLVariables = new URLVariables();
urlVars.sendInfo = "blabla";
var urlReq:URLRequest = new URLRequest("website/getPlayerFromDB.php");
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlReq.data = urlVars;
urlReq.method = URLRequestMethod.POST;
urlLoader.addEventListener(Event.COMPLETE,comp);
urlLoader.load(urlReq);
function comp(e:Event):void {
var vars:URLVariables = new URLVariables(e.target.data);
for(var i in vars)
trace(i+": "+vars*);
}
And here’s the php code:
<?php
$info = $_POST['stuff'];
echo "result=".$info;
?>