I've done a little research and I can't find a way to query any object to determine if a sound is playing. You'll have to write a wrapper class and manage it yourself it seems.
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;
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…