1
votes

Usually we load external swf file into Flash using 'Loader' class.

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:

[Embed("my-external-swf.swf")]
public var component:Class;

Is it possible to tell 'Loader' to load from embedded content instead?

2

2 Answers

1
votes

You should be able to simply do this:

addChild(new component());

Hopefully the name component won't collide with any reserved variables.

If you still would like to use the Loader class, as @Lukasz advises, use the loadBytes() method and pass the embedded asset. If your swf also contains code, you might need to initialize the LoaderContext:

var ctx:LoaderContext = new LoaderContext(false,this.loaderInfo.applicationDomain);
ctx.allowCodeImport = true;
Loader(addChild(new Loader())).loadBytes(new Components(),ctx);
2
votes

I think you should use loadBytes of Loader class, similar to described solution here: how to embed swf file