AS3套接字无法加载数据

时间:2016-01-25 14:30:47

标签: actionscript-3 sockets flash

我已经搜索了很多次互联网,但找不到任何线索。我正在使用套接字连接到套接字服务器。 (我们也尝试了不同的套接字策略文件,但都没有工作)

    private var SERVER_URL : String = "http://192.168.0.105";
    private var PORT_NUMBER : int = 1435;

    private var _socket : Socket;

    // signal
    private var _signal : Signal;

    public function BackendService()
    {
        // nastavenie socketu
        _socket = new Socket();
        _socket.addEventListener(Event.CONNECT, connectHandler);
        _socket.addEventListener(Event.CLOSE, closeHandler);
        _socket.addEventListener(ErrorEvent.ERROR, errorHandler);
        _socket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
        _socket.addEventListener(ProgressEvent.SOCKET_DATA, HandleMsgFromServer); // ak pride sprava zo serveru

        Security.allowDomain("*");
        Security.allowInsecureDomain("*");
        Security.loadPolicyFile("http://192.168.0.105:8000/crossdomain.xml"); 

        // signal na dispatchovanie eventov
        _signal = new Signal();

        connect(); // I am doing it from other class, but for sake of example, I am calling from here
    }

    public function connect():void
    {
        _socket.connect(SERVER_URL, PORT_NUMBER);
    }

我的跨域 - 套接字策略文件位于端口8000上,如下所示:

<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

我收到此错误:

  

错误#2044:未处理的securityError:。 text =错误#2048:安全性   沙箱违规:   file:/// C:/projects/TennisHeroes/bin/TennisHeroes.swf无法加载数据   来自http://192.168.0.105:1435

非常感谢您的任何建议!

0 个答案:

没有答案