Skip to content

Instantly share code, notes, and snippets.

@nicolechung
Created March 22, 2012 12:03
Show Gist options
  • Save nicolechung/2157936 to your computer and use it in GitHub Desktop.
Save nicolechung/2157936 to your computer and use it in GitHub Desktop.
Actionscript: Send Data to PHP
public function sendData(url:String, vars:URLVariables)
{
var req:URLRequest = new URLRequest(url);
req.data = vars;
req.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT; // URLLoaderDataFormat.VARIABLES will cause error #2101
loader.load(req);
loader.addEventListener(Event.COMPLETE, loadComplete, false, 0, true);
}
private function loadComplete(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
trace(loader.data); // php result
ExternalInterface.call( "console.log" , loader.data); // view in browser
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment