·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[AS3]as3和PHP程序的交互技巧整理(4)

时间:2012-03-13 18:03CuPlayer.com
第四种 GET 传参 System.useCodePage=true; btn.addEventListener(MouseEvent.CLICK,loadTxt); function loadTxt(evt:MouseEvent):void { var urlLoader:URLLoader=new URLLoader(); var request:URLRequest=new UR

第四种 GET 传参

System.useCodePage=true;
btn.addEventListener(MouseEvent.CLICK,loadTxt);
function loadTxt(evt:MouseEvent):void
{
var urlLoader:URLLoader=new URLLoader();
var request:URLRequest=new URLRequest();
request.url="http://www.baidu.com/s";
request.method=URLRequestMethod.GET;
request.data="wd=flash";
urlLoader.load(request);
urlLoader.addEventListener(Event.COMPLETE,finish);
}
function finish(evt:Event):void
{
mytxt.text=(evt.currentTarget as URLLoader).data;
}

第五种 POST 传参

System.useCodePage=true;
btn.addEventListener(MouseEvent.CLICK,loadTxt);
function loadTxt(evt:MouseEvent):void
{
var urlLoader:URLLoader=new URLLoader();
var request:URLRequest=new URLRequest();
var vars:URLVariables=new URLVariables();
vars.wd="flash";
request.url="http://www.baidu.com/s";
request.method=URLRequestMethod.GET;
request.data=vars;
urlLoader.load(request);
urlLoader.addEventListener(Event.COMPLETE,finish);
}
function finish(evt:Event):void
{
mytxt.text=(evt.currentTarget as URLLoader).data;
}
这里data是URLVariables是值对,注意区别

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器