mysong = new Sound();
mysong.attachSound("sd");
mysong.onSoundComplete = function()
{
mysong.start(0,0);
};
mysong.start(0,0);//使声音在动画开始时播放
var soundkey = 1;//定义变量soundkey,监视声音播放情况
var stopPosition;//设置一个变量储存音乐的停止位置
_root.btn1.onRelease = function()
{
soundkey = -soundkey;//使变量值为原值相反数
if (soundkey == 1)
{
mysong.start(stopPosition);
//记录下停止时播放的位置,赋值给变量b;
_root.info.text="停在第"+stopPosition+"秒";//在bb文本框内显示当前停止的位置;
}
//如果soundkey值为正,则播放声音,mysong.stop()使声音停止后再播,以免声音产生叠加,影响效果
if (soundkey == -1)
{
mysong.stop();
stopPosition=int(mysong.position/1000);
}
};