A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: fading my music up

  1. #1
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80

    fading my music up

    terrible trouble trying to fade my music up. When the time line enters the frame I have this code to start the music.


    mySound = new Sound();
    mySound.attachSound("music");
    mySound.start("", 999);

    the time line moves to the next frame and stops.

    Please help.

  2. #2
    Senior Member
    Join Date
    Nov 2003
    Posts
    524
    Hi,
    create a function to fade up the music.

    Code:
    mySound = new Sound();
    mySound.attachSound("music");
    mySound.start("", 999); 
    sounfFadeIncrement=5;
    
    function fadeUp(){
    //this sets a timer that calls your fadeSound function every 100 
    //milliseconds (aprox 1/10 second).
    fadeInterval=setInterval(fadeSound,100);
    }
    
    function fadeSound(){
      Volume=mySound.getVolume();
      if(Volume<100){
       mySound.setVolume(Volume+soundFadeIncrement);
      }
      else{
      clearInterval(fadeInterval);
      }
    }
    Then call the function on the second frame with

    fadeUp();

    Hope that helps
    Shipstern

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