Sep
24
ActionScript 3: Send GET/POST
Filed Under (Uncategorized) by ashardi on 24-09-2011
At the office, we recently developing some digital signage products, which requiring ActionScript to take part. So, here is a little code snippet of how to send GET/POST variables from AS3:
import flash.net.*;
var url:String = "http://192.168.1.1:1234/";
var request:URLRequest = new URLRequest(url);
request.method = URLRequestMethod.GET;
var variables:URLVariables = new URLVariables();
variables.name = "Anton Ashardi";
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.load(request);
function onComplete (event:Event):void {
trace(event.target.data);
}



