2011-12-11 36 views
0

我正在使用這種技術來重新啓動遊戲。下面是代碼:我可以刪除舊的SWF並同時加載另一個SWF嗎?

function restart(e:MouseEvent) { 
    if (myLoader) { 
    removeChild(myLoader) 
      myLoader = null 
    } 
    myLoader = new Loader();      // create a new instance of the Loader class 
    var url:URLRequest = new URLRequest("aaa.swf"); // in this case both SWFs are in the same folder 
    myLoader.load(url);          // load the SWF file 
    addChild(myLoader); 
} 

我的問題是,每個重新啓動遊戲時的時候,它是越來越少流暢動畫,如果你知道我的意思。我想,那是因爲舊的SWF仍然在框架中,並放慢了新的速度。有沒有辦法加載新的SWF,但同時刪除舊的? 我剛剛複製了此代碼,因此我無法確定此代碼是否刪除舊的SWF。先謝謝您:)

回答

0

嘗試myLoader.unload()刪除它之前...也使用FlashBuilder分析器來查看舊的實例是否仍在內存中。

相關問題