How do you loop a sound in flash AS3 when it ends?

后端 未结 8 1522
北海茫月
北海茫月 2020-12-16 02:47

What AS3 code is used to loop a sound using AS3?

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 03:14

    this work for me :

    import flash.media.Sound;
    import flash.media.SoundChannel;
    
    var soundUrl:String ="music.mp3";
    var soundChannel:SoundChannel = new SoundChannel();
    var sound:Sound = new Sound();
    
    sound.load(new URLRequest(soundUrl));
    soundChannel = sound.play();
    soundChannel.addEventListener(Event.SOUND_COMPLETE,onComplete);
    
    function onComplete(e:Event):void{
        sound = new Sound();
        sound.load(new URLRequest(soundUrl));
        soundChannel = sound.play();
        soundChannel.addEventListener(Event.SOUND_COMPLETE,onComplete);
    }
    

提交回复
热议问题