智慧 + 毅力 = 无所不能

正确性、健壮性、可靠性、效率、易用性、可读性、可复用性、兼容性、可移植性...

导航

As3 模拟As2.0LoadVars 传参

Posted on 2009-12-01 09:32  Bill Yuan  阅读(201)  评论(0编辑  收藏  举报
代码
var myRequest:URLRequest = new URLRequest("http://www.webstudio.com.cn/msg.php");
var myLoader:URLLoader = new URLLoader();
var myVariables:URLVariables = new URLVariables();

myLoader.addEventListener(Event.COMPLETE, loadSuccessful);
myLoader.addEventListener(IOErrorEvent.IO_ERROR, loadError);

myVariables.var1 
= "hello";
myVariables.var2 
= "hi";

myRequest.method 
= URLRequestMethod.POST;
myRequest.data 
= myVariables;

myLoader.load(myRequest);

function loadSuccessful($evt:Event):void
{
    trace(
"参数已发送");
}

function loadError($evt:IOErrorEvent):void
{
    trace(
"发送失败.");
}