有没有办法让 flash-app 仅在我的页面(域)上运行,而不是在本地或其他域上运行?
我创建了一些游戏,想让用户只在我的域上玩它,因此禁止离线玩它或放在其他网站上。有办法做到吗?以某种方式检查域等?
I created some game and would like to let the users play it only on my domain, so to forbid to play it offline or put on some other site. Is there a way to do it? Somehow check domain or so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管很难明确控制 Flash 内容的分发,但您可以采用几种不同的途径,至少可以使在其他地方发布内容变得更加困难。
一种方法是检查加载 swf 对象的 url 是从 LoaderInfo 类。
您还可以使用 JavaScript 通过 ExternalInterface 类:
然后检查 url 以查看它是否位于您所需的域内,如下所示:
您可以在本文中找到有关此方法的一些其他信息:
http://www.ghostwire.com/blog/archives/as3- domain-locking-swfs/
另一种方法是尝试从您控制的域下载文件,如果您已经将外部资源下载到您的 swf,这种方法尤其有效。
通过指定资产的绝对 URL,例如
http://www.example.com/assets/myExternalAsset.xml
,而不是相对 URL,例如/assets/myExternalAsset.xml< /code>,你可以设置一个跨域策略 确定哪些域能够访问内容。
如果从允许的域之外访问内容,将触发安全错误事件并且下载将无法完成。
话虽如此,例如,如果您的内容嵌入到另一个网站的 iframe 元素内,我并不完全确定上述任何方法是否能够充分保护您。
Although it's hard to definitively control the distribution of your Flash content, there are a few different routes you can go down to, at least, make it harder to publish your content somewhere else.
One way is to check what url are loading the swf object is to check
loaderInfo.loaderURL
from the LoaderInfo class.You can also check the loading url by using JavaScript through the ExternalInterface class:
Then check the url to see that it resides within your desired domain, like this:
You can find some additional information about this approach in this article:
http://www.ghostwire.com/blog/archives/as3-domain-locking-swfs/
Another approach is to try to download a file from a domain you control, this is especially effective if you are already downloading external assets to your swf.
By specifying an absolute url to the asset, like
http://www.example.com/assets/myExternalAsset.xml
, instead of a relative one, like/assets/myExternalAsset.xml
, you can set up a cross-domain-policy to determine what domains are able to access the content.If the content is accessed from outside of your allowed domain(s), a security error event will be triggered and the download will not complete.
Having said this, I'm not fully sure if any of the above methods will fully protect you if your content, for example, is embedded inside of an iframe element on another site.