1 Reply Latest reply on Apr 18, 2007 2:27 PM by 914_6

    sound control button

    mikearamark
      hi all,
      i bought a flash template for my personal site and it has a sountrack on it with a music on/off button at bottom of screen.
      for my portfolio section, i'd like to showcase some video work that has sound as well
      if i leave soundtrack on - they play over each other, if i turn soundtrack off - can't hear video
      is there a script so that i can have soundtrack turn off or fade out when video is playing and then come back on when done?
      thanks for your help
        • 1. sound control button
          914_6 Level 1
          You will have to create multiple sound objects, then create each one a button to control it. The following action will create a sound object. Place it in the first frame of the timeline on a layer called actionSound:

          //here you create the new sound object
          mySound1 = new Sound();
          //here you associate the sound file track1 to the sound object mySound
          //you have to give the sound file in the library a linkage name (here its track1)
          //to do this, click on the sound file in the library, then choose linkage, then check Export for ActionScript, then enter track1
          mySound1.attachSound("track1");
          //if you want this sound object to run at the start, leave the following line, otherwise, drop it
          mySound1.start(0,1000);


          Repeat those lines of code for as many individual track you need, giving each soundObject a new name. But dont start them using the start(0,1000) command, or they will run one over the other. ONLY your background soundtrack should be started first.

          To activate the individual sounds and desactivate soundtrack, place this code on each button that will control the sounds:

          on (release) {
          //first we stop all sounds (soundtrack as well as others if any are running)
          stopAllSounds();
          //then we activate the soundObject you want, in that case mySound2
          //remember we create them earlier
          mySound2.start(0,1000);
          }


          Paste the same code on each button and replace mySound2 by mySound3, mySound4, etc.

          This is the simpliest way to do it. But it may cause problems with the preloading stuff. There is a workaround for that too. One problem at the time, right?

          Hope that helped.