2014-12-03 35 views
0

我在每個SWF文件中有一個簡單的swf加載程序例程。swf的深嵌套工作只有一個級別深

a.swf負載/添加b.swfb.swf負載/添加c.swf

當我運行b.swf我清楚地看到c.swf加載

但是當我運行a.swf,我看到b.swf但不c.swf

注:我得到類的參考,手動實例化並添加它顯示,但只有1層深。以下例程重用於每個加載程序。

編輯它的工作原理,如果我使用this.onResult(loader.content)代替this.onResult(new classRef());但我需要得到它正在爲classRef

public function load():void { 
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); 
     loader.load(new URLRequest(this.url)); 
    } 

    private function completeHandler(event:Event):void { 
     var className:String = getQualifiedClassName(loader.content); 
     var classRef:Class = loader.contentLoaderInfo.applicationDomain.getDefinition(className) as Class; 
     this.onResult(new classRef()); 
    } 

enter image description here

enter image description here

回答

0

試試這個:

public function load():void { 
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); 
    loader.load(new URLRequest(this.url), new LoaderContext(false, ApplicationDomain.currentDomain)); 
} 
+0

我試過,但它沒有工作,它的工作方式,如果我使用'this.onResult(event.target.content)',傷心知道。讓我爲了更清晰地重複問題。嵌套SWF只是無法顯示(加載正常)它的子SWF或換句話說,大孩子無法添加到顯示 – user2727195 2014-12-04 15:54:09

+0

我通過創建簡單的3 fla文件(a.fla,b.fla,c.fla each關聯的.as文件),並且它在'classRef'或'event.target.content'這兩種情況下都能很好地工作,這意味着我的代碼有問題。在後臺,'new classRef()'被傳送到父文檔類並被添加到那裏。有趣的'新的classRef()'不起作用,但'event.target.content'在我的代碼中起作用。 – user2727195 2014-12-04 17:30:51