在我的代码中,我定义了Sound,SoundChannel和URLRequest,如下所示:
private var url:String = "MySound.mp3";
private var oSound:Sound;
private var oSoundChannel:SoundChannel;
...
var request:URLRequest = new URLRequest(url);
this.oSound = new Sound();
this.oSound.load(request);
用户可以选择新的声音并进行更改。这个过程(我的意思是改变声音)可以重复。 如下所示:
this.oSoundChannel.stop();
this.url = "deejay.mp3";
var request:URLRequest = new URLRequest(this.url);
this.oSound = new Sound();
this.oSound.load(request);
this.oSoundChannel = oSound.play();
我的问题(关于内存泄漏/丢失): 是否需要在加载新声音文件之前删除对象(例如Sound,SoundChannel或URLRequest)? 如果是,我该如何删除这样的元素?
// E.g. something like: oSound.parent.removeChild(oSound); // <-- It doesn't work properly!
提前致谢。