从另一个SWF里提取它的类/静态变量
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/*
* 加载swf文件舞台中的 元件
*/
var loadsub:Loader = new Loader();
var swf:URLRequest = new URLRequest("../bin/ss.swf");
var t2:MovieClip;
loadsub.load(swf);
//loadsub.x = 200;
loadsub.contentLoaderInfo.addEventListener(Event.COMPLETE, addtoStage);
function addtoStage(e:Event):void
{
t2 = (loadsub.content as MovieClip).t2;//t2为元件的实名
addChild(t2);
t2.x = 0;
t2.y = 0;
}
/*加载swf中的某个类
*
* 需要设置 swf中被加载的 元件 Export for ActionScript
*
* 在库中右键点击某个 movie Clip->properties->勾选Export for ActionScript
* 勾选了这个 导出的 swf文件大小 会增加
*/
var loader : Loader = new Loader();
var context : LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain);
context.applicationDomain = ApplicationDomain.currentDomain;
//context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader.load(new URLRequest("../bin/ss.swf"), context);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadcom);
function loadcom(the:Event):void
{
var runtimeClassRef:Class = getClass("t1");
var greeter:MovieClip = new runtimeClassRef();
addChild(greeter);
greeter.x=100;
greeter.y=200;
function getClass(className:String):Class
{
return loader.contentLoaderInfo.applicationDomain.getDefinition(className) as Class;
}
}