更新时间:2022-11-28 10:20:17
为什么要注释对 addEventListener
方法的调用?取消注释(并将其向上移动两行,使其出现在 load
调用之前).如果 url 正确,当响应到达时将调用 processASP
方法(在现实生活中的应用程序中,请确保您在 URLLoader - 检查链接以获取有关执行此操作的示例).您可以在 processASP
方法中将响应读取为 e.target.data
.
Why have you commented the call to addEventListener
method? Uncomment it (and move it up two lines so that it comes before the load
call). If the url is correct, the processASP
method will be called when the response arrives (in a real life application, make sure you listen for ioError and securityError on the URLLoader - check the link for examples on doing this). You can read the response as e.target.data
in the processASP
method.
private function processASP(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
trace("Response is " + loader.data);
}
URLLoader
也可以用来向asp页面(服务器)发送数据.
URLLoader
can also be used to send data to the asp page (server).
var ldr:URLLoader = new URLLoader();
var data:URLVariables = new URLVariables();
data.something = "someData";
data.somethingElse = "moreData";
var request:URLRequest = new URLRequest("url.asp");
request.data = data;
request.method = URLRequestMethod.POST;//or GET
ldr.addEventListener(Event.COMPLETE, onLoad);
//listen for other events
ldr.load(request);