[英]Load SWF from embedded file in Flash
Usually we load external swf file into Flash using 'Loader' class. 通常我们使用'Loader'类将外部swf文件加载到Flash中。
var loader:Loader = new Loader();
loader.load(new URLRequest("http://domain/path/my-external-swf.swf"));
However, the external swf file is now embedded in my flash document: 但是,外部swf文件现在嵌入在我的flash文档中:
[Embed("my-external-swf.swf")]
public var component:Class;
Is it possible to tell 'Loader' to load from embedded content instead? 是否有可能告诉“Loader”从嵌入式内容加载?
我认为你应该使用Loader类的loadBytes,类似于这里描述的解决方案: 如何嵌入swf文件
You should be able to simply do this: 你应该能够简单地这样做:
addChild(new component());
Hopefully the name component
won't collide with any reserved variables. 希望name
component
不会与任何保留变量冲突。
If you still would like to use the Loader class, as @Lukasz advises, use the loadBytes() method and pass the embedded asset. 如果你仍然想使用Loader类,就像@Lukasz建议的那样,使用loadBytes()方法并传递嵌入的资产。 If your swf also contains code, you might need to initialize the LoaderContext :
如果你的swf也包含代码,你可能需要初始化LoaderContext :
var ctx:LoaderContext = new LoaderContext(false,this.loaderInfo.applicationDomain);
ctx.allowCodeImport = true;
Loader(addChild(new Loader())).loadBytes(new Components(),ctx);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.