简体   繁体   English

在Flash(AS3)中使用“加载程序”加载其他SWF文件后,删除SWF文件

[英]Remove SWF file after loading a Different SWF file using “Loader” in Flash (AS3)

I am trying to load multiple swf files. 我正在尝试加载多个SWF文件。 But the problem is that whenever I load them (back and forth; vice-versa), my file keeps on slowing down. 但是问题在于,每当我加载它们(来回;反之亦然)时,我的文件就会继续减速。 I looked a solution from the internet, such as using "unload" and "removeChild" but I can't get a clear solution and I don't know where to put it. 我从互联网上看了一个解决方案,例如使用“ unload”和“ removeChild”,但是我找不到一个明确的解决方案,也不知道该放在哪里。 Any help is very much appreciated..Here's my code on how I load my swfs: 非常感谢您的帮助。这是我如何加载swfs的代码:

MainMenu.swf: MainMenu.swf:

//***************CLICK GALLERY*********************//
Gallery_btn.addEventListener(MouseEvent.CLICK, Gallery);

function Gallery(event:MouseEvent):void{

    var ldr1:Loader=new Loader();
    ldr1.load(new URLRequest("Gallery.swf"));
    addChild(ldr1);

}

Gallery.swf: Gallery.swf:

//***************CLICK QUIT******************//
Quit_btn.addEventListener(MouseEvent.CLICK, Quit);

function Quit(event:MouseEvent):void{

    var ldr1:Loader=new Loader();
    ldr1.load(new URLRequest("MainMenu.swf"));
    addChild(ldr1);
}

You need to use removeChild and remove every listener. 您需要使用removeChild并删除每个侦听器。 You can unload swf by calling unload on your loader or unloadAndStop. 您可以通过在加载程序或unloadAndStop上调用unload来卸载swf。

You can read this article for more information. 您可以阅读本文以获取更多信息。

UnloadAndStop from Adobe 从Adobe卸载并停止

Unload SWF 卸载SWF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM