mercredi 17 février 2016

Actionscript 3 remove sound object

In my code I define Sound, SoundChannel and URLRequest like below:

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);

The user can select a new sound and change it. This process (I mean change the sound) can be repeated. Like below:

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();

My question (in relation to memory leak / loss): Is it needed to remove an object (e.g. Sound, SoundChannel or URLRequest) before loading a new sound-file? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire