ASが運営するWebサイトに飛びます

2008年02月24日

[復習] 外部で読み込んだサウンドを停止する

外部で読み込んだサウンドを停止するには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);


posted by 神風記 at 00:00| メモ(復習 走り書き) | このブログの読者になる | 更新情報をチェックする