gpt4 book ai didi

apache-flex - 如何使用 Flash (AS3) 从远程域调用 Flex SWF?

转载 作者:行者123 更新时间:2023-12-02 07:16:34 25 4
gpt4 key购买 nike

我在 http://www.a.com/a.swf 上托管了一个 Flex swf .我在另一个尝试加载 SWF 的域上有一个闪存代码:

_loader = new Loader();
var req:URLRequest = new URLRequest("http://services.nuconomy.com/n.swf");
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderFinish);
_loader.load(req);

在 onLoaderFinish 事件中,我尝试从远程 SWF 加载类并创建它们:

_loader.contentLoaderInfo.applicationDomain.getDefinition("someClassName") as Class

当这段代码运行时我得到以下异常

SecurityError: Error #2119: Security sandbox violation: caller http://localhost.service:1234/flashTest/Main.swf cannot access LoaderInfo.applicationDomain owned by http://www.b.com/b.swf.
at flash.display::LoaderInfo/get applicationDomain()
at NuconomyLoader/onLoaderFinish()

有什么方法可以使这段代码正常工作吗?

最佳答案

这在The Adobe Flex 3 Programming ActionScript 3 PDF 中都有描述。第 550 页(第 27 章:Flash Player 安全性/跨脚本):

If two SWF files written with ActionScript 3.0 are served from different domains—for example, http://siteA.com/swfA.swf and http://siteB.com/swfB.swf—then, by default, Flash Player does not allow swfA.swf to script swfB.swf, nor swfB.swf to script swfA.swf. A SWF file gives permission to SWF files from other domains by calling Security.allowDomain(). By calling Security.allowDomain("siteA.com"), swfB.swf gives SWF files from siteA.com permission to script it.

它继续更详细,有图表等等。

关于apache-flex - 如何使用 Flash (AS3) 从远程域调用 Flex SWF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com