开发者

Is it possible to bypass the cross-domain.xml requirement for an Adobe AIR application built with Flex?

开发者 https://www.devze.com 2022-12-27 18:56 出处:网络
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?

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=f开发者_高级运维alse 
    eventPhase=2 
    text="Error #2048: Security sandbox violation: app:/MyApp.swf cannot 
            load data from gmail.com:5222." errorID=0
]


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号