2007-06-16

Loading External module-SWF

參考 ActionScript 3 Tip of the Day: Loading External Classes with ApplicationDomain

載入模組測試
load_module_loadee01.fla 包含 linkaged symbol: Symbol1
load_module_loader01.fla
var my_this = this;
var ldr:Loader = new Loader();
var ldrContext:LoaderContext = new LoaderContext();
// 使用 loader 的類別域
ldrContext.applicationDomain = ApplicationDomain.currentDomain;
ldr.load(new URLRequest("load_module_loadee01.swf"), ldrContext);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);

function onComplete(e:Event):void{
/*
var Symbol1:Class =
ApplicationDomain.currentDomain.getDefinition('Symbol1')
as Class;
*/
var Symbol1:Class = getDefinitionByName('Symbol1')
as Class;

var s:MovieClip = new Symbol1();
this.addChild(s);
}

原始檔: load_module_01.zip

沒有留言:

FB 留言