As3 模拟As2.0 LoadVars传参

AS3.0 中已经没有了loadVars. 对于习惯使用AS2.0 loadVars传参的可以参考一下.

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("发送失败.");
}

 
 

posted @ 2008-10-23 10:01  Landy_di  阅读(280)  评论(0)    收藏  举报