如何从远程域使用Flash(AS3)调用Flex的SWF? [英] How do I call a Flex SWF from a remote domain using Flash (AS3)?

查看:146
本文介绍了如何从远程域使用Flash(AS3)调用Flex的SWF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主持 http://www.a.com/a.swf。 我有另一个doamin试图加载的SWF闪光code:

I have a Flex swf hosted at http://www.a.com/a.swf. I have a flash code on another doamin that tries loading the 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加载类和创建它们:

On the onLoaderFinish event I try to load classes from the remote SWF and create them:

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

在此code运行时我得到了以下异常

When this code runs I get the following exception

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()

有没有什么办法让这个code工作?

Is there any way to get this code working?

推荐答案

这是所有的 Adob​​e的Flex 3的编程ActionScript 3的PDF上页550(第27章:Flash Player安全性/跨脚本):

This is all described in The Adobe Flex 3 Programming ActionScript 3 PDF on page 550 (Chapter 27: Flash Player Security / Cross-scripting):

如果使用ActionScript 3.0编写的两个SWF文件是从不同的服务领域,例如, http://siteA.com /swfA.swf http://siteB.com/swfB.swf - 然后,默认情况下,Flash播放器既不允许swfA.swf脚本swfB.swf也,也不swfB.swf也为脚本swfA.swf。的SWF文件中调用Security.allowDomain授予权限,以从其他域的SWF文件()。通过调用Security.allowDomain(siteA.com),swfB.swf也给出了从siteA.com许可的SWF文件的脚本了。

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.

它继续在一些细节,以图表和所有的。

It goes on in some more detail, with diagrams and all.

这篇关于如何从远程域使用Flash(AS3)调用Flex的SWF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆