Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 动作脚本3删除声音对象_Actionscript 3_Audio - Fatal编程技术网

Actionscript 3 动作脚本3删除声音对象

Actionscript 3 动作脚本3删除声音对象,actionscript-3,audio,Actionscript 3,Audio,在我的代码中,我定义了声音、声音频道和URL请求,如下所示: 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.oSo

在我的代码中,我定义了声音、声音频道和URL请求,如下所示:

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();
用户可以选择新的声音并进行更改。这个过程(我的意思是改变声音)可以重复。 如下图所示:

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();
我的问题(关于内存泄漏/丢失): 在加载新的声音文件之前,是否需要删除对象(例如声音、SoundChannel或URLRequest)? 如果是,如何删除该元素

// E.g. something like: oSound.parent.removeChild(oSound); // <-- It doesn't work properly!

//例如:oSound.parent.removeChild(oSound);//
oSound=nullif(oSound==null){oSound=new Sound()}
这个问题被误导了。你不能从任何东西上移除声音对象。像AS3中的每个对象一样,您将它们限定为GC。