2011-09-19 51 views
0

我一直在搞亂我的AS3代碼試圖找到一種方法來獲取加載的SWF,通過按下加載的SWF中的te close_btn來卸載。 我似乎無法得到這個工作,所以也許你們知道一種方法來做到這一點。AS3從加載的SWF本身卸載SWF

so:

main_swf加載swf_1。

而在swf_1中是close_btn,它應該卸載swf_1。

讓我們回到main_swf。

任何想法?

回答

0

main_swf有一個loader它加載您的swf_1

我的建議是: 如果close_btnswf_1的主舞臺上。當close_btn被點擊:

function handleClose (e : MouseEvent) : void 
{ 
    // this needs to be in the root section of the swf_1 
    this.dispatchEvent (new Event (Event.CLOSE)); 
} 

main_swf裏面的swf_1後已加載:

loader.content.addEventListener (Event.CLOSE, handleContentClosed); 

function handleContentClosed (e : Event) : void 
{ 
    // removing the event listener, making the content ready for GC 
    loader.content.removeEventListener(Event.CLOSE, handleContentClosed); 
    // removing the actual content from the place it was added 
    removeChild (loader.content); 
    // unloading and stoppping the loaded swf 
    loader.unloadAndStop(); 
}  

更多信息有關unloadAndStop()