AIR应用程序没有与浏览器中的Flash Player相同的域策略。因此,您通常不需要AIR应用程序的跨域策略文件。但是有时空中会抛出安全错误事件,可以忽略。下面是一个例子:
<?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>