public class NetLoad
{
/**发送数据*/
private var _loader:URLLoader;
/**url请求*/
private var _req:URLRequest;
/**回调函数*/
private var _callBack:Function;
public function NetLoad()
{
}
/**传数据*/
public function upload(url:String, data:Object, callBack:Function):void
{
var _url:String = LoginData.getInstanc().testURL + url + "pid=" + data.pid + "&pwd=" + data.pwd;
_req = new URLRequest(url);
// _req.data = data;
_req.contentType = "application/octet-stream";
_req.method = URLRequestMethod.POST;
_loader = new URLLoader();
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.load(_req);
_loader.addEventListener(Event.COMPLETE, uploadHandler);
_callBack = callBack;
}
/**传输完毕*/
private function uploadHandler(e:Event):void
{
var bytes:ByteArray = e.target.data as ByteArray;
var data:Object;
data = AdobeJSON.decode(bytes.toString());
}
}
connection.call("EasyAMF.setData", responderSet, info1);这种应该是调用一个js函数,responderSet和info1是js函数的参数。
407646653回答的是flash向php传数据,并接收php传回的数据。这是两种不同的传递数据方式。
var url:String = "http://www.[yourDomain].com/application.jsp";
var request:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
variables.exampleUserLabel = "guest";
request.data = variables;
navigateToURL(request);
这个是发送数据
如果想要接受的话
用load()方法
完成获取complete事件