Created
March 22, 2012 12:03
-
-
Save nicolechung/2157936 to your computer and use it in GitHub Desktop.
Actionscript: Send Data to PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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