关于一个声音的问题,知道的来看看!!
找到了,谢谢了!
//播放声音
song_sound = new Sound();
song_sound.attachSound("a_thousand_ways");
song_sound.start();
song_sound.onSoundComplete = function() { //创建了在调用 onSoundComplete 事件时执行的函数,onSoundComplete 为声音播放完毕时自动调用的事件,这样,当声音播放完毕后自动执行mysong.start(),使声音不断播放。
song_sound.start() }//播放声音
//循环播放声音
var stopPosition;//设置一个变量储存音乐的停止位置
bt1.onRelease=function(){//当鼠标按下暂停按钮的时候
song_sound.stop();//音乐停止
stopPosition=song_sound.position/0;//声音停止位置的时间付值给stopPosition
}
bt2.onRelease=function(){//当鼠标按下开始按钮的时候
song_sound.start(stopPosition);//从stopPosition位置开始播放
} //全部结束(sound对象的position属性取得当前声音文件的播放时间(毫秒),你可以用它来制作进度条。原理同load条的加载类)
//点击停止和播放按钮
play_btn.onRelease = function() {
song_sound.start();
};
stop_btn.onRelease = function() {
song_sound.stop();
};
//音量控制
this.createTextField("volume_txt", 10, 30, 30, 200, 20);
volume_mc.top = volume_mc._y;
volume_mc.bottom = volume_mc._y;
volume_mc.left = volume_mc._x;
volume_mc.right = volume_mc._x + 155;
volume_mc._x += 100;
volume_mc.handle_btn.onPress = function() {
startDrag(this._parent, false, this._parent.left, this._parent.top, this._parent.right, this._parent.bottom);
};
volume_mc.handle_btn.onRelease = function() {
stopDrag();
var level:Number = Math.ceil(this._parent._x - this._parent.left);
this._parent._parent.song_sound.setVolume(level);
this._parent._parent.volume_txt.text = level;
};
volume_mc.handle_btn.onReleaseOutside = slider_mc.handle_btn.onRelease;