开发者

Open swf file than works with socket

开发者 https://www.devze.com 2023-04-09 23:06 出处:网络
Sorry for my bad English. I have the following problem: I have a .fla file, that works with Socket class. There is a server(written in Delphi XE, but it does not matter). I connect to it from my .fl

Sorry for my bad English.

I have the following problem:

I have a .fla file, that works with Socket class. There is a server(written in Delphi XE, but it does not matter). I connect to it from my .fla. When i execute my .fla from within Flash Professional CS5 everything works fine. But when i tried to execute resulting .swf from Explorer(Win 7, Flash Player 10) i got an error:

SecurityError: Error #2010: Local-with-filesystem SWF files are not
 permitted to use sockets. at flash.net::Socket/internalConnect() at
 flash.net::Socket/connect() at payterminal::TLogger() at
 payterminal::TMainTerminalClass() at
 testterminal_fla::MainTimeline/frame1()

Socket connects to the server as follows:

Sock.connect('127.0.0.1', 5243);

I tried to change setting "Local playback security" in "File->Publish settings" to "Access network only.

Ok. Flash player starts without errors, but it's send to server the following message:

<policy-file-request/>

After this socket connection closes.

I also tried to use the method Security.AllowDomain(), but it did not made no positive results.

There was another method i tried. The server has two listening sockets. The first listening on port 843. When this socket receive the message policy-file-request it send to .swf the crossdomain file, like this:

 <?xml version="1.0"?>  <!DOCTYPE cross-domain-policy SYSTEM
 "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">  <!-- Policy
 file for xmlsocket://socks.mysite.co开发者_如何学Gom -->  <cross-domain-policy>  
     <allow-access-from domain="*"/>  
 </cross-domain-policy>

After it the socket(843) closes. But the second listening socket gets the same message: .

After all this, my .swf is still open in Flash Player with no errors, but the socket connection is not happening. I tried different crossdomain-files, but all my attempts led me to same result.

That's the problem i have. I look forward to your help. Thanks.


user976479 this is perfectly normal behavior.
Flash player will first try to obtain the master xml policy file on port 843 and then try 5243 if it doesn't find a master.
Once the server responds to the request for the crossdomain flash player will close the connection(always).
I use the following crossdomain.xml for my socket server.
Remember once the domain policy is recieved you have to have the flash player reconnect a second time. The second time you will not be disconnected.

<?xml version="1.0" encoding="UTF-8" ?>
  <cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd">
  <allow-access-from domain="*" to-ports="*"  />
</cross-domain-policy>

One last thing. use a port higher then 10k as the lower ports are usually reserved for other applications and there maybe be a conflict with that.


There is no problem with your cross-domain file.

Flash player's security features do not allow a local (file:// protocol) file to access the internet. To test your swf in a browser, you'll have to upload it to your server and then test it.

Or, you could download a server to install on your local machine for testing. I use wampserver

EDIT: Since you are already running a local server, try uploading to that. Then access your swf as http://127.0.0.1/mySwf.swf

0

精彩评论

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

关注公众号