3 Replies Latest reply on Dec 8, 2006 4:53 PM by Newsgroup_User

    Trouble with both sounds stopping when only one should

    jrmcintosh
      Ok. I will try to explain this the best I can.

      I have a main swf that loads other swfs into it when certain buttons are clicked.

      On the main swf I have an audio on|off button (called audio_mc) that fades out the background music when clicked off and fades in when clicked on. The background audio file that is specified in the actionscript is called mysound within the linkage of the audio file and within the actionscript for audio_mc, mysound is called to be the audio file that fades in or out.

      I have a section where I want to play videos in a swf that loads. When I click on a video I want the background music (mysound) to fade out and the video audio to play. When I click the video button it called _root.audio_mc.fadedown(); which is my function to fadedown the background music.

      The problem is that not only does my background music fade out but also the video audio fades out with it. I don't understand why this happens as in the audio_mc actionscript it specifically calls mysound and doesn't specify anything regarding the video.

      Please let me know if I need to attach code.

      Thanks to anyone who can help,
      Jason
        • 1. Re: Trouble with both sounds stopping when only one should
          Level 7
          Jason,

          > The problem is that not only does my background
          > music fade out but also the video audio fades out
          > with it. I don't understand why this happens as
          > in the audio_mc actionscript it specifically
          > calls mysound and doesn't specify anything
          > regarding the video.

          My hunch is that this is the result of how you instantiated your Sound
          object. If you supplied a movie clip reference as a parameter, your
          audio for that instance would be "paired up" with the provided movie
          clip. In this way, you can instantiate any number of Sound objects
          associated to individual timelines, and thus get individual control. If
          you supplied nothing as a parameter, settings such as volume, pan, and
          so on apply globally.

          See this article for details.

          http://www.quip.net/blog/2006/flash/actionscript-20/understanding-the-sound-constructor


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."
          • 2. Re: Trouble with both sounds stopping when only one should
            jrmcintosh Level 1
            David, thank you for the blog, that was very helpful but I think my issue is a similar but different so I'm going to attach some code. Maybe you can help me with it, cause it's quite a quandry...
            • 3. Re: Trouble with both sounds stopping when only one   should
              Level 7
              jrmcintosh wrote:
              > //This is the code that runs when I click on a button that loads a video into
              > an empty movie clip and tries to fade the
              > //background audio, but in turn fades both the background audio and the video
              > within the movie clip.
              > //audio_mc is the instance name for the on/off button
              >

              Wow, I'm sorry for the delay in my reply. I've been watching this
              thread, but somehow lost track of it. In your sample code, the only
              instance of Sound I see is the s variable, which is associated with a
              movie clip with the instance name bgsound. I haven't seen any code
              inside the SWF that contains your video, so maybe there's something
              there? I'm surprised, actually, at how often people load video by
              placing it into a SWF first ... FLVs can be loaded directly into main SWFs.

              Even if you or I can't see it, something is obviously going on here to
              cause the unexpected behavior. ;) At this point, some good old
              fashioned trouble shooting is in order.

              Keep things as clean as possible -- nothing extra to add unnecessary
              complexity. I suggest loading the FLV into your main SWF directly,
              rather than wrapping it in its own SWF.

              http://www.quip.net/blog/2006/flash/how-to-load-external-video

              I recommend attempting this in a new FLA -- again, where nothing else
              is there to distract you from your sleuthing. Introduce a Sound
              instance ... forget all that other code, just create a variable ...

              var s:Sound = new Sound();

              ... load or attach your audio asset to that Sound instance, then invoke
              Sound.setVolume() by hand to see if it affects the audio of both. At
              this point, it should, because the Sound() constructor has no parameter.
              Next, create an empty movie clip and give it an instance name.
              Provide that name as your Sound() parameter and run it again. Try these
              "baby steps" first until the concepts really gel. I do this sort of
              "back to basics" exercise all the time, and it often brings something to
              light that I hadn't seen before.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."