Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3 URLRequest POST仅在HTML包装器中编译时有效_Actionscript 3_Apache Flex_Urlrequest - Fatal编程技术网

Actionscript 3 AS3 URLRequest POST仅在HTML包装器中编译时有效

Actionscript 3 AS3 URLRequest POST仅在HTML包装器中编译时有效,actionscript-3,apache-flex,urlrequest,Actionscript 3,Apache Flex,Urlrequest,我正试图使用以下代码将包含数据的POST请求发送到另一个域: _snapshot_id = 1369022400; var urlRequest:URLRequest = new URLRequest("https://fuzzykittens/radar"); urlRequest.method = URLRequestMethod.POST; urlRequest.contentType = "application/x-www-form-urlencoded"; //set variab

我正试图使用以下代码将包含数据的POST请求发送到另一个域:

_snapshot_id = 1369022400;
var urlRequest:URLRequest = new URLRequest("https://fuzzykittens/radar");
urlRequest.method = URLRequestMethod.POST;
urlRequest.contentType = "application/x-www-form-urlencoded";

//set variables for post
var postVars:URLVariables = new URLVariables();
postVars.snapshot = String(_snapshot_id);
urlRequest.data = postVars;

//initialize weather proccess request
weatherProcRequest = new URLLoader(urlRequest);

weatherProcRequest.addEventListener(Event.COMPLETE,
    weatherProcRequest_CompleteHandler);
weatherProcRequest.addEventListener(IOErrorEvent.IO_ERROR,
    weatherProcRequest_ErrorHandler);
weatherProcRequest.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
    weatherProcRequest_ErrorHandler);

weatherProcRequest.load(urlRequest);
当我将flex编译器设置为使用HTML包装器时,请求就起作用了。当我不使用包装器时,请求会抛出一个io错误#2032。我想它没有发送快照id,但我不知道为什么

在html包装器中调试时,请求会发送数据,而在html包装器外部调试时却无法发送数据,这有什么明显的原因吗

fuzzykittens有一个带有

<allow-access-from domain="*" secure="false"/>

我发现了问题。Adobe在URLRequest的livedoc中非常简要地提到了这一警告:

注意:如果在Flash Player中运行并且引用的表单没有正文,Flash Player将自动使用GET操作,即使该方法设置为URLRequestMethod.POST。因此,建议始终包括一个“虚拟”主体,以确保使用正确的方法

当我只是在没有主体的情况下运行SWF时,快照id没有作为post var发送,因此服务器的响应不同


这肯定不是我想要的答案,但知道发生了什么感觉很好。感谢您的评论。

更具体地描述您的环境可能会有所帮助(您是在桌面或移动应用程序中使用AIR,还是只是尝试自行执行SWF,如果是,原因是什么?)根据SWF执行的上下文,存在不同的安全限制。我正在自行运行SWF。这样做的决定不是我自己的,所以我不知道为什么。当我使用HTML包装时,它是在firefox中打开的。谢谢,这是我的第一个堆栈溢出问题。这可能是在不使用包装器的情况下使用URLRequestMethod.POST时,请使用URLRequestMethod.GET进行测试。您还可以在URLLoader上侦听HTTPStatusEvent.HTTP_状态和HTTPStatusEvent.HTTP_响应_状态,以查看返回的状态