打开 swf 文件而不是使用套接字
抱歉我的英语不好。
我有以下问题:
我有一个 .fla 文件,适用于 Socket 类。有一个服务器(用Delphi XE写的,不过没关系)。我从我的 .fla 连接到它。 当我从 Flash Professional CS5 中执行 .fla 时,一切正常。但是,当我尝试从资源管理器(Win 7、Flash Player 10)执行生成的 .swf 时,出现错误:
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 连接到服务器如下:
Sock.connect('127.0.0.1', 5243);
我尝试将“文件 - >发布设置”中的“本地播放安全性”设置更改为“仅访问网络。
好的。Flash播放器启动时没有错误,但它向服务器发送以下消息:
<policy-file-request/>
在此套接字连接之后 我也
尝试使用 Security.AllowDomain() 方法,但没有取得任何积极结果。
我尝试了另一种方法,第一个侦听端口 843。消息策略文件请求它发送到.swf跨域文件,如下所示:
<?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.com --> <cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
之后套接字(843)关闭。 但第二个侦听套接字收到相同的消息: 。
毕竟,我的 .swf 仍然在 Flash Player 中打开,没有错误,但套接字连接没有发生。 我尝试了不同的跨域文件,但所有尝试都导致了相同的结果。
这就是我遇到的问题。我期待您的帮助。谢谢。
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.com --> <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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
user976479 这是完全正常的行为。
Flash Player 将首先尝试在端口 843 上获取主 xml 策略文件,如果找不到主,则尝试 5243。
一旦服务器响应跨域flash播放器的请求,就会关闭连接(总是)。
我将以下 crossdomain.xml 用于我的套接字服务器。
请记住,一旦收到域策略,您必须让 Flash 播放器再次重新连接。第二次您将不会断开连接。
最后一件事。
使用高于 10k 的端口,因为较低的端口通常保留给其他应用程序,可能会发生冲突。
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.
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.
你的跨域文件没有问题。
Flash 播放器的安全功能不允许本地(file:// 协议)文件访问 Internet。要在浏览器中测试您的 swf,您必须将其上传到您的服务器,然后进行测试。
或者,您可以下载服务器安装在本地计算机上进行测试。
我使用 wampserver
编辑:由于您已经在运行本地服务器,请尝试上传到该服务器。然后访问您的 swf http://127.0.0.1/mySwf.swf
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