卸瑞士法郎使用unloadAndStop()方法,但视频声音保持可听瑞士法郎、可听、声音、方法

2023-09-08 11:46:35 作者:孤魂

我已经尝试了许多方法来卸我的SWF,但无济于事,视频的声音在我的laoded SWF保持甚至一度SWF已加载播放。

I have tried many approaches to unloading my swf, but to no avail, the video sounds within my laoded swf keep playing even once the swf has been loaded.

我创建了一个通用的加载程序如下:

I have created a universal loader as follows:

var loader:Loader = new Loader();

我然后加载不同的swf的到一个名为的影片剪辑的 mov_contentLoader ,例如视频SWF加载如下:

I then load various swf's into a movie clip named mov_contentLoader, for example the video swf is loaded as follows:

loader.load(new URLRequest("video.swf")); //assign SWF url to loader
mov_contentLoader.addChild(loader); //add loaded content to movi clip

然后,我有一个通用的退出按钮,根据应用程序的状态,某些窗口关闭,SWF的被卸载等等。对于我video.swf文件,点击退出按钮时,我所说的unloadAndStop( );对装载机方法如下:

I then have a generic "exit" button, based on the state of the application, certain windows are closed, swf's are unloaded etc. For my video.swf file, when the exit button is clicked, I call the unloadAndStop(); method on the loader as follows:

loader.unloadAndStop(); //unload all content, do some garbage cleanup
mov_contentLoader.removeChildAt(0); //just to be safe, a second layer of reassurance ??

中的SWF被卸载,但对我的生活我不能让声音停止!我甚至使出增加对video.swf舞台监听器监听的退出状态,但依然没有停止视频的声音。

The SWF is unloaded, but for the life of me I can NOT get the sounds to stop! I even resorted to adding stage listeners on the video.swf to listen for an exiting state, but that still did not stop video sounds.

如果我再次加载video.swf并播放不同的视频,两个音轨播放ontop对方。

If I load the video.swf in again and play a different video, the two soundtracks play ontop of each other.

任何指导,一如既往,大大接受美联社preciated。

Any guidance, as always, is greatly accepted and appreciated.

西蒙

推荐答案

大量的研究后,我已经解决了这个问题。在希望这会使一个人的生活轻松了许多,这里是这个问题:

After much research I have solved this problem. In the hope that this will make someone's life a lot easier, here was the issue:

unloadAndStop(); 方法删除所有事件侦听器,实例,对象等从加载的SWF。在我来说,我有视频,并且如果视频还在播放,当用户退出(和加载卸载的内容)的声音将会继续。看来,一件事 unloadAndStop(); 函数不能做的是停止所有声音

The unloadAndStop(); method removes any event listeners, instances, objects etc from the loaded SWF. In my case I had videos, and IF the video was still playing when the user exited (and the loaded unloaded the content) the sounds would carry on. It seems that one thing the unloadAndStop(); function does NOT do is stop all sounds.

该如何解决?我连着一个事件监听器给我的装载机,和之后的内容被成功卸载,我叫 SoundMixer.stopAll(); 功能,确保不会玩携带的声音!该然而意味着,如果你有环境背景声音,一直以来,他们就停止了。你可以更进一步,让你周围的声音当前时间和简单的重启他们立即从该时间点。

The solution? I attached an event listener to my loader, and after the content was successfully UNLOADED, I called the SoundMixer.stopAll(); function which ensured no sounds carried on playing! This DOES however mean that if you had ambient background sounds all along, they would stop too. You could go even further and get the current time of your ambient sounds and simply "restart" them immediately from that point in time.

我的简单发泄监听器看起来是这样的:

My simple vent listener looks like this:

myloader.contentLoaderInfo.addEventListener(Event.UNLOAD, cleanUp);

function cleanUp(e:Event):void{
   SoundMixer.stopAll(); //stop all sounds...
}

我相信,这将帮助别人!这是一个有点哈克,但它的工作就好了。

I trust this will help someone! It's a little "hacky" but it does the job just fine.

亲切的问候, 西蒙