打印

[编程] 为什么我的背景音乐只播放一次?

我的flash的Action如下:

_root.bnstyle2.gotoAndStop(20);
_root.about.gotoAndStop(20);
logo2_mc._y = 16.500000;
snd._y = 42.300000;
createEmptyMovieClip("bg_snd",this.getNextHighestDepth());
var songTrack = new Sound(bg_snd);
var mysound = new Sound();
mysound.attachSound("music");
songTrack.onLoad = function ()
{
};
songTrack.onSoundComplete = function ()
{
    snd_play();
};
playSound = function ()
{
    songTrack.loadSound("01.wav", true);
};
snd.stop();
snd.onPress = function ()
{
    if (snd._currentframe == 1)
    {
        snd_stop();
    }
    else
    {
        snd_play();
    } // end if
};
snd_play = function ()
{
    snd.gotoAndStop(1);
    num = 0;
    mysound.start();
    snd_status = "play";
    this.onEnterFrame = function ()
    {
        num = num + 5;
        songTrack.setVolume(num);
        if (num >= 40)
        {
            delete this["onEnterFrame"];
        } // end if
    };
};
snd_stop = function ()
{
    snd.gotoAndStop(2);
    num = 40;
    this.onEnterFrame = function ()
    {
        num = num - 5;
        songTrack.setVolume(num);
        mysound.stop();
        if (num <= 0)
        {
            songTrack.stop();
            snd_status = "stop";
            delete this["onEnterFrame"];
        } // end if
    };
};
snd_play();
snd.x1 = 931;
snd.x2 = 793;

很长一串,我自己都没看懂,

具体:我再总结一下我的问题: 就是一个音乐开关,按下play ,只播放一次,我希望他循环播放。

如何改代码???谢谢啊

[ 本帖最后由 kaka7 于 2008-6-26 15:52 编辑 ]
1.mysound.start(0,1000);
2.mySound.onSoundComplete = function (){
mySound.start();
}
mySound = new Sound();//设置对象
mySound.setVolume(100);//声音的大小
mySound.loadSound("Music/Music_kn.mp3",true);//加载音乐
mySound.onSoundComplete = function() {
       mySound.start();//当播放完后重新播放
};
on(release){
       _parent._parent.mySound.stop();//当点击按钮后停止播放
}
on(release){
       _parent._parent.mySound.start();//当点击按钮后开始播放
}

以上的代码是在论坛的一位朋友指点下完成的。

希望能帮到你
上面两位都正解,主要就是你没设置循环播放或循环的次数

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!