package
{
import flash.display.MovieClip;
import flash.media.SoundTransform;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundCodec;
import flash.media.SoundChannel
import flash.events.MouseEvent;
/**
* ...
* @author ...
*/
public class sound_mc extends MovieClip
{
var pausePoint:Number = 0.00;
var isPlaying:Boolean;
var soundChannel:SoundChannel = new SoundChannel();
var sound:Sound = new Sound(new URLRequest("trip.mp3"));
public function sound_mc():void {
trace("sound_mc");
_sound();
}
private function _sound():void {
//聲音部分START
soundChannel = sound.play(0,999);///從第一秒開始播,放999次
isPlaying = true;
_AREA.buttonMode = true;
_AREA.addEventListener(MouseEvent.CLICK,clickStop)
}
private function clickStop(evt:MouseEvent) {
if (isPlaying) {
soundChannel.stop();
trace("停止");
isPlaying = false;
_ICO.gotoAndStop(2);
} else {
trace("繼續播");
soundChannel = sound.play(0,999);
isPlaying = true;
_ICO.gotoAndStop(1);
}
pausePoint = 0.00;
}
}
}
//--------------------------------------------------------------------------------------
人家寫好的sound_mc_fla檔
(download_fla)
sound_mc物件必須繼承com.frogiology.sound_mc <=這支as檔案
來源網址
http://blog.frogiology.com/2008/09/07/flash-tweener-lesson3-10-usages/
//最基本播放聲音as---------------------------------------------------------------------------
//_bug是原件庫的物件匯出給as使用叫做_bug
var sound=new _bug();
var channel:SoundChannel = new SoundChannel();
channel=sound.play(0,999);//播放999次
//關閉聲音function
function closesound() {
channel.stop();
channel=null;
}
//最基本單純播放聲音-------------------------------------------------------------------------------
No comments:
Post a Comment