embedded mp3 in actionscript3 won't play all the way through

前端 未结 4 1479
余生分开走
余生分开走 2021-01-06 05:47

I embedded an mp3 file be used as background music for my app. Though it works fine, the problem is that it doesn\'t play the whole track, it just plays the first 32 seconds

4条回答
  •  攒了一身酷
    2021-01-06 06:54

    Your background Sound instance is probably getting garbage collected., since you're not maintaining a reference to it. Try this:

    package 
    {
        import flash.display.Sprite;
        import flash.media.Sound;
        import flash.media.SoundChannel;
    
        public class BackgroundMusic extends Sprite
        {
            [Embed(source="swfs/bg.mp3")]       
            private var BG:Class;
    
            private var _backgroundMusic:Sound;
    
            public function BackgroundMusic() 
            {   
                _backgroundMusic = new BG();
                _backgroundMusic.play();
            }
       }
    }
    

提交回复
热议问题