Reputation: 481
I have 2 SWF, one of them (let's call it Resources.swf
), that contains several symbols (most of them MovieClips) on its library, but, none of them are added into the stage ( the timeline contains only one empty frame),
and then, the other swf (Main.swf
), where I need to import some of the symbols from the other SWF.
I have been looking around, and searching, but all the info that I saw, and tried, imports the symbols from the stage/timeline using things like:
loadedMC = MovieClip(loader.content);
or
loadedMC = MovieClip(event.target.content);
My symbols have a class definition, because, they are also used in other swf this way:
[Embed(source='assets/Resources.swf', symbol='SymbolName')]
public class Generic2 extends MovieClip
Is there any way to do this?
If not,do I have modify my Resources.swf to work this out or do I have other alternatives?
Upvotes: 1
Views: 6653
Reputation: 34247
Follow these steps
Helper Function
public function createInstance(mc:MovieClip, className:String, instName:String):MovieClip
{
var cls:Class = mc.loaderInfo.applicationDomain.getDefinition(className) as Class;
if (cls)
{
var instMC:MovieClip = new cls();
instMC.name = instName;
return instMC;
}
return null;
}
Upvotes: 2
Reputation: 1
You need to have a as3 class, or just to export the symbol in the frame otherwise you can't reference it. Your swf will be empty if you don't export your movieclip... Basically you can just export it as a Certain class and then reference the empty class!
Upvotes: 0
Reputation: 20210
After loading the Resources.swf you can create instances of the loaded classes.
Here a snippet that may help:
var dynClass : Class = Class(getDefinitionByName("fully.qualified.ClassName"));
if(dynClass)
{
var app : Object = new dynClass();
addChild(app as DisplayObject);
}
Upvotes: 2