A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Loading Multiple External Music Files

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    2

    Loading Multiple External Music Files

    I am working on a photo gallery with music and everything works good except I can not seem to load multiple music files one right after another. This is the code I have that works with one music file. If someone can please help me be able to load another after the first song ends that would be great?

  2. #2
    Junior Member
    Join Date
    Sep 2010
    Posts
    2
    Oops! I forgot to add the actionscript code. Here is what I got right now:


    var music:Sound = new Sound(new URLRequest("WeddingPage.mp3"));
    var sc:SoundChannel = music.play(0,int.MAX_VALUE);
    var isPlaying:Boolean = true;
    var pos:Number = 0

    //---Music Off Button---//

    musicOff_btn.addEventListener(MouseEvent.CLICK, stopMusic);

    function stopMusic(e:Event):void
    {
    if (sc != null)
    {
    sc.stop();
    pos = 0;
    isPlaying = false;
    }
    }

    //---Music On Button---//

    musicOn_btn.addEventListener(MouseEvent.CLICK, playMusic);

    function playMusic(e:Event):void
    {
    if(!isPlaying)
    {
    sc = music.play(pos);
    isPlaying = true;
    }
    }

    //---Music Pause Button---//

    pause_btn.addEventListener(MouseEvent.CLICK, pauseMusic);

    function pauseMusic(e:Event):void
    {
    if(isPlaying)
    {
    pos = sc.position;
    sc.stop();
    isPlaying = false;
    }
    }

    //---Volume Slider---//

    var dragging:Boolean = false;
    var rectangle:Rectangle = new Rectangle(0,0,100,0);
    volume_mc.slider_mc.addEventListener(MouseEvent.MO USE_DOWN, dragIt);
    stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);

    function dragIt(e:Event):void
    {
    volume_mc.slider_mc.startDrag(false,rectangle);
    dragging = true;
    volume_mc.slider_mc.addEventListener(Event.ENTER_F RAME, adjustVolume);
    }

    function dropIt(e:Event):void
    {
    if (dragging)
    {
    volume_mc.slider_mc.stopDrag();
    dragging = false;
    }
    }

    function adjustVolume(e:Event):void
    {
    var vol:Number = volume_mc.slider_mc.x / 100
    var st:SoundTransform = new SoundTransform(vol);
    if (sc != null)
    {
    sc.soundTransform = st;
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center