loadermax获取swf的限定类名

时间:2014-12-02 19:59:27

标签: actionscript-3 greensock

典型的as3代码就像这样

private function load():void {
        var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

        if(Security.sandboxType == Security.REMOTE) {
            loaderContext.securityDomain = SecurityDomain.currentDomain;
        }

        loader.contentLoaderInfo.addEventListener(Event.INIT, handleInit);
        loader.load(new URLRequest("capture.swf"), loaderContext);
    }

    private function handleInit(event:Event){
        var className:String = getQualifiedClassName(loader.content);
        var classRef:Class = loader.contentLoaderInfo.applicationDomain.getDefinition(className) as Class;
        var captureModule = new classRef();
        addChild(captureModule as DisplayObject);
    }

现在在使用greensock的loadermax时,我如何访问限定类名,它的引用,自己创建一个对象并添加到显示中。

loaderMax.append(new SWFLoader("capture.swf", {name:"capture"}));
loaderMax.append(new SWFLoader("filter.swf", {name:"filter"}));
loaderMax.load();

loadComplete函数

        function completeHandler(event:LoaderEvent): void {
            trace(event.target + " is complete");
            var capture = loaderMax.getContent("capture");
            trace(getQualifiedClassName(capture)); //want to reach the custom class of the loaded sf
        }

1 个答案:

答案 0 :(得分:0)

证明加载的swf有一个属性loaderInfo.loader,你可以访问它来使用加载器。

var loader = loaderMax.getContent("capture").rawContent.loaderInfo.loader;
this.data["capture"] = loader.contentLoaderInfo.applicationDomain.getDefinition(getQualifiedClassName(loaderMax.getContent("capture").rawContent)) as Class;