How to send a GET request in AS3?

◇◆丶佛笑我妖孽 提交于 2019-12-10 13:38:36

问题


I see this example here: http://damn.ihateblue.net/2011/09/24/actionscript-3-send-getpost/

Which looks pretty good. But the loader seems overly complicated. What if I don't need to listen for a response? Can this be simplified?


回答1:


If you don't want to listen for a response then you can remove the dataFormat, the listener and its handler function. You can also leave out the request.method because GET is the default.

import flash.net.*;
var url:String = "http://192.168.1.1:1234/";
var request:URLRequest = new URLRequest(url);

var variables:URLVariables = new URLVariables();
variables.name = "Anton Ashardi";
request.data = variables;

var loader:URLLoader = new URLLoader();
loader.load(request);

If you don't want to send any data along with your request you can also omit the central code block.



来源:https://stackoverflow.com/questions/8746670/how-to-send-a-get-request-in-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!