外部で読み込んだサウンドを停止するにはsoundChannelオブジェクトを使用します。音楽ファイルを読み込んだsoundオブジェクトをsoundChannelオブジェクトに代入する。そのsoundChannleオブジェクト.stopメソッドで再生が停止される
ソースコード
var sample_so:Sound=new Sound();
var channel:SoundChannel;
sample_so.addEventListener(Event.COMPLETE,completeHandler);
sample_so.load(new URLRequest("sample.mp3"));
function completeHandler(evt:Event) { channel=sample_so.play(); }
function stopHandler(evt:Event) { channel.stop(); }
stopBtn.addEventListener(MouseEvent.CLICK,stopHandler);
|