我做了一些研究,我找不到查询任何对象的方法来确定是否正在播放声音.你必须编写一个包装类并自己管理它.
package { import flash.events.Event; import flash.media.Sound; import flash.media.SoundChannel; public class SoundPlayer { [Embed(source="song.mp3")] private var Song:Class; private var s:Song; private var ch:SoundChannel; private var isSoundPlaying:Boolean; public function SoundPlayer() { s = new Song(); play(); } public function play():void { if(!isPlaying) { ch = s.play(); ch.addEventListener( Event.SOUND_COMPLETE, handleSoundComplete); isSoundPlaying = true; } } public function stop():void { if(isPlaying) { ch.stop(); isSoundPlaying = false; } } private function handleSoundComplete(ev:Event):void { isSoundPlaying = false; } } }