对于使用 Flex 构建的 Adob​​e AIR 应用程序,是否可以绕过 cross-domain.xml 要求? [英] Is it possible to bypass the cross-domain.xml requirement for an Adobe AIR application built with Flex?

查看:22
本文介绍了对于使用 Flex 构建的 Adob​​e AIR 应用程序,是否可以绕过 cross-domain.xml 要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Adobe AIR 应用程序是否可以连接到不公开跨域.xml 文件的删除网络服务?如果是这样,您如何在 Air 中配置安全沙箱以允许这样做?

Is it possible for an Adobe AIR application to connect to a remove webservice that does not expose a cross-domain.xml file? If so, how do you configure the security sandbox within Air to allow this?

我尝试建立套接字连接并收到以下错误:

I have attempted a socket connection and received the following error:

securityErrorHandler: 
[SecurityErrorEvent 
    type="securityError" 
    bubbles=false 
    cancelable=false 
    eventPhase=2 
    text="Error #2048: Security sandbox violation: app:/MyApp.swf cannot 
            load data from gmail.com:5222." errorID=0
]

推荐答案

AIR 应用程序没有与浏览器中的 Flash Player 相同的域策略.因此,您通常不需要 AIR 应用程序的跨域策略文件.但是,有时 AIR 会抛出可以忽略的 SecurityErrorEvent.下面是一个例子:

AIR applications do not have a same domain policy like Flash Player in the browser. So you do not usually need cross domain policy files with AIR apps. However sometimes AIR will throw SecurityErrorEvent's that can be ignored. Here is an example:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml">

  <mx:applicationComplete>
    <![CDATA[
      var s:Socket = new Socket();
      s.addEventListener(ProgressEvent.SOCKET_DATA, function(event:ProgressEvent):void {
        t.text += event.target.readUTFBytes(event.target.bytesAvailable);
      });
      s.addEventListener(Event.CONNECT, function(event:Event):void {
        t.text += "Event.CONNECT\n\n";
        s.writeUTF("GET / HTTP/1.0\n\n");
      });
      s.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(event:SecurityErrorEvent):void {
        trace('security sandbox error ignored');
      });
      s.connect("www.jamesward.com", 80);
    ]]>
  </mx:applicationComplete>

  <mx:TextArea id="t" width="100%" height="100%"/>

</mx:WindowedApplication>

这篇关于对于使用 Flex 构建的 Adob​​e AIR 应用程序,是否可以绕过 cross-domain.xml 要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆