非常简单的URLLoader封装,支持参数和回调函数,默认POST。
public static function HttpRequest(url:String, parms:Array, callback:Function):void{
var _request:URLRequest = new URLRequest(url);
var _vars:URLVariables = new URLVariables();
var _loader:URLLoader;
var i:int;
for (i = 0; i < parms.length;i++ ){
_vars[parms[i][0]] = parms[i][1];
}
_request.method = URLRequestMethod.POST;
_request.data = _vars;
_loader = new URLLoader(_request);
_loader.addEventListener(Event.COMPLETE, callback);
_loader.load(_request);
}