[英]complete unload external swf and sound
I am using this code for load and unload an external swf for a button. 我正在使用此代码加载和卸载按钮的外部swf。 when I click on button, swf loads and when again I click on button swf unloads, but sound still exist and just swf screen disappeares.
当我单击按钮时,swf加载,再次单击按钮时,swf卸载,但是声音仍然存在,只是swf屏幕消失了。
Please correct this code, I want swf to completetely unload. 请更正此代码,我希望swf完全卸载。
printer.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);
var fl_Loader:Loader;
//This variable keeps track of whether you want to load or unload the SWF
var fl_ToLoad:Boolean = true;
function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
{
if(fl_ToLoad)
{
fl_Loader = new Loader();
addChild(fl_Loader);
fl_Loader.load(new URLRequest("quiz.swf"));
printer.x=100;
printer.y=100;
}
else
{ fl_Loader.unloadAndStop();
removeChild(fl_Loader);
fl_Loader = null;
printer.x=155;
printer.y=334;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad = !fl_ToLoad;
}
If you can access the code in loaded swf than you may add Event.UNLOAD
listener. 如果可以访问已加载的swf中的代码,则可以添加
Event.UNLOAD
侦听器。 In the event handler you can do some cleaning: 在事件处理程序中,您可以进行一些清理:
Stage
) Stage
事件侦听器) This way, the unloading should be smooth and easy. 这样,卸载应该是平稳且容易的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.