
Код AS3:
package
{
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.Event;
import flash.net.URLRequest;
public class MyClass
{
public var snd:Sound;
public var channel:SoundChannel;
public function MyClass()
{
snd = new Sound();
snd.addEventListener(Event.COMPLETE, completeHandler);
snd.load(new URLRequest("sound.mp3"));
}
private function completeHandler(evt:Event):void
{
channel = snd.play();
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
}
private function soundCompleteHandler(evt:Event):void
{
channel.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
channel = snd.play();
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
}
}
}
как-то так