Flash加载swf文件的沙箱问题

1. 本地运行SWF文件
I. 加载本地swf文件
在as3代码中:
var ctx:LoaderContext = new LoaderContext(true ,new ApplicationDomain(null));
var urlFont:String = "D:/fonts.swf";
ld.load(new URLRequest(urlFont),  ctx);

在控制面板FlashPlayer或者Flash插件上右键->全局设置->高级->开发人员工具->受信任的位置设置->添加:
1.被调用的swf文件(fonts.swf)所在目录(这里是d:/)
2.自己的swf文件所在目录

即可。否则,如果b.swf是字体文件,registerFont时总是出现错误
[Fault] exception, information=ArgumentError: Error #1508: 为参数 font 指定的值无效。

参考附件LoadEmbedFont.zip

II. 加载网络swf文件
被调用的swf文件部署的网络必须放置crossdomain.xml并正确描述,但是不能使用上述代码,请参考附件FontTest.zip

2. 网络运行SWF文件
III. 加载本地swf文件
Flash中,这个是不允许的!

IV. 加载网络swf文件
请使用方法II。

变异参数 -use-network 总保持true,上述例子都可WORK.
如果在IDE中设置use-network,参考下面某人提供的关于SandBox的问题描述:
引用
The error message you posted shows that you're trying to load a local file from a local swf. This error can be fixed for your scenario.

In FlashDevelop, set "Use Network Services" to false (Project Properties -> Compiler Options tab). This will prevent your swf from accessing the internet but will let you load local files. Setting it to true will allow internet access but not access to local files.

In Flash, the setting is under "Publish Settings", Flash tab. It's called "Local playback security" and the settings are "Access local files only" or "Access network only". It's the same setting as in FlashDevelop, just a different name.

You can also switch the "Use Network" flag of a swf file after publish/compile by using the Adobe's free+open Local Content Updater.

你可能感兴趣的:(Flash)