AS3与PHP通信的五种方法(基于HTTP协议)(3)
* 第四种:通过POST方法把参数传到PHP里面 www.2cto.com
*/
//--------------------------------------------------------------------------
phpUrl.method = URLRequestMethod.POST;
var vars:URLVariables = new URLVariables();
vars.value1 = "参数1";
vars.value2 = "参数2";
phpUrl.data = vars;
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlLoader.load(phpUrl);
urlLoader.addEventListener(Event.COMPLETE, completeHandler4);
//--------------------------------------------------------------------------
/**
* 第五种:二进制通信方法
*/
//----------------------------------------------------------------------------
var requestHeader:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
phpUrl.method = URLRequestMethod.POST;
phpUrl.requestHeaders.push(requestHeader);
var byteArr:ByteArray = new ByteArray();
byteArr.writeByte(12);
byteArr.writeUTF("CNSloppyMan");
var sendData:ByteArray = new ByteArray();
sendData.writeInt(byteArr.length);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>