10 Replies Latest reply on May 11, 2006 3:17 PM by Newsgroup_User

    replay movie doesn't include sound

    DPSwebmaster Level 1
      I have a flash file which plays a movie I am loading via AS

      with the SCRIPT

      var sndTrack:Sound = new Sound();
      sndTrack.loadSound("sound/mysoundmp3", true);

      I also have a replay button at the end of the movie with the script

      on (release) {
      gotoAndPlay(1);

      var sndTrack:Sound = new Sound();
      sndTrack.loadSound("sound/chickychicky.mp3", true);

      }

      the replay works, but with no sound.

      any ideas why?
        • 1. Re: replay movie doesn't include sound
          Level 7
          //var sndTrack:Sound = new Sound();
          Variable is scoped to only exist in the onRelease function, so when the
          onRelease function ends the variable is removed from memory which is just
          about instantly.

          Place the following line on frame 1 of the timeline.
          var sndTrack:Sound = new Sound();
          and remove it from the onRelease function.


          You also might considering learning more about the Sound class. Rather than
          reloading the mp3 over and over again you could consider loading it one time
          say on frame 1 and using the start and stop methods elsewhere in the movie.
          var sndTrack1:Sound = new Sound();
          sndTrack1.loadSound("sound/mysoundmp3", true);
          var sndTrack2:Sound = new Sound();
          sndTrack2.loadSound("sound/chickychicky.mp3", true);

          Then where you want to play
          sndTrack1.start()

          sndTrack2.start()

          Then where you want to stop
          sndTrack1.stop()

          sndTrack2.stop()

          --
          Lon Hosford
          www.lonhosford.com
          May many happy bits flow your way!
          "DPSwebmaster" <webforumsuser@macromedia.com> wrote in message
          news:e3g2h5$5jp$1@forums.macromedia.com...
          I have a flash file which plays a movie I am loading via AS

          with the SCRIPT

          var sndTrack:Sound = new Sound();
          sndTrack.loadSound("sound/mysoundmp3", true);

          I also have a replay button at the end of the movie with the script

          on (release) {
          gotoAndPlay(1);

          var sndTrack:Sound = new Sound();
          sndTrack.loadSound("sound/chickychicky.mp3", true);

          }

          the replay works, but with no sound.

          any ideas why?


          • 2. Re: replay movie doesn't include sound
            DPSwebmaster Level 1
            works except this part.

            Then where you want to play
            sndTrack1.start()

            sndTrack2.start()

            Then where you want to stop
            sndTrack1.stop()

            say i have a layer with the music I have loaded in frame one with the AS mentioned above, where and how would I place the start and stop functions?

            do I add the frame number in between the ()?

            sorry to be so dense. I am a beginning action scripter.
            • 3. Re: replay movie doesn't include sound
              DPSwebmaster Level 1
              o.k duh, I just put the action on which ever frame I want to start and stop...now I am understanding a bit better.
              • 4. Re: replay movie doesn't include sound
                Level 7
                Originally it appeared me you had two sounds you are playing starting with
                on and then switching to another.

                Since you are only playing one sound and then replaying it, then on frame 1

                var my_sound:Sound = new Sound();
                // if the sound loads, play it; if not, trace failure loading
                my_sound.onLoad = function(success:Boolean) {
                if (success) {
                my_sound.start();
                trace("Sound loaded");
                } else {
                trace("Sound load failed");
                }
                };
                // load the sound
                my_sound.loadSound("sound/chickychicky.mp3", true);

                On your button
                on (release) {
                gotoAndPlay(1);

                my_sound.start();
                }

                --
                Lon Hosford
                www.lonhosford.com
                May many happy bits flow your way!
                "DPSwebmaster" <webforumsuser@macromedia.com> wrote in message
                news:e3iku2$a9k$1@forums.macromedia.com...
                works except this part.

                Then where you want to play
                sndTrack1.start()

                sndTrack2.start()

                Then where you want to stop
                sndTrack1.stop()

                say i have a layer with the music I have loaded in frame one with the AS
                mentioned above, where and how would I place the start and stop functions?`
                on (release) {
                gotoAndPlay(1);

                sndTrack1.stop()
                sndTrack2.start()

                }


                do I add the frame number in between the ()?

                sorry to be so dense. I am a beginning action scripter.


                • 5. Re: replay movie doesn't include sound
                  DPSwebmaster Level 1
                  this works for me in my test file, but in the flash website I am working with it doesn't work :-(

                  I think was is causing the problem is the site is built as a main flash page which loads other swf's. The sound and replay button for instance are on my home.swf file which is being loaded into the index.swf file. so maybe I need to adjust part of my code or place it elsewhere? Again, the sound is being loaded into the home.swf file which gets loaded into the .index.swf file....gets kind of confusing...
                  • 6. Re: replay movie doesn't include sound
                    Level 7
                    Does the swf work on its own on the web site and not as a part of the the
                    other swfs? Perhaps there is a relative folder addressing issue and you may
                    need to reference the file absolutely:

                    trace (_url.split("/").pop())
                    urlBase = _url.substr(0,_url.lastIndexOf("/")+1)
                    trace (urlBase)

                    my_sound.loadSound(urlBase + "sound/chickychicky.mp3", true);



                    --
                    Lon Hosford
                    www.lonhosford.com
                    May many happy bits flow your way!
                    "DPSwebmaster" <webforumsuser@macromedia.com> wrote in message
                    news:e3ot3g$doq$1@forums.macromedia.com...
                    this works for me in my test file, but in the flash website I am working
                    with
                    it doesn't work :-(

                    I think was is causing the problem is the site is built as a main flash
                    page
                    which loads other swf's. The sound and replay button for instance are on my
                    home.swf file which is being loaded into the index.swf file. so maybe I need
                    to
                    adjust part of my code or place it elsewhere? Again, the sound is being
                    loaded
                    into the home.swf file which gets loaded into the .index.swf file....gets
                    kind
                    of confusing...


                    • 7. Re: replay movie doesn't include sound
                      DPSwebmaster Level 1
                      I'll try that last suggestion, where would I need to place this code, on line 1 here I am loading the sound file or on my replay button?
                      • 8. Re: replay movie doesn't include sound
                        Level 7
                        Loading the file.

                        --
                        Lon Hosford
                        www.lonhosford.com
                        May many happy bits flow your way!
                        "DPSwebmaster" <webforumsuser@macromedia.com> wrote in message
                        news:e3qa2v$9hj$1@forums.macromedia.com...
                        I'll try that last suggestion, where would I need to place this code, on
                        line 1 here I am loading the sound file or on my replay button?


                        • 9. Re: replay movie doesn't include sound
                          DPSwebmaster Level 1
                          I finally have everything working, but I am having trouble getting the music to delay a certian number of frames before starting.

                          in the AS I tried:

                          var my_sound:Sound = new Sound();
                          // if the sound loads, play it; if not, trace failure loading
                          my_sound.onLoad = function(success:Boolean) {
                          if (success) {
                          my_sound.start();
                          trace("Sound loaded");
                          } else {
                          trace("Sound load failed");
                          }
                          };
                          // load the sound
                          my_sound.start(15, 0);
                          trace (_url.split("/").pop())
                          urlBase = _url.substr(0,_url.lastIndexOf("/")+1)
                          trace (urlBase)

                          my_sound.loadSound(urlBase + "sound/chickychicky.mp3", true);

                          which should play the music beginning on the 15th frame of the animation, correct?

                          the music starts right away and ends before the animation. I am looking to synch the music better with the animtion and I am having some difficulty with this.

                          • 10. Re: replay movie doesn't include sound
                            Level 7
                            Frame 1:
                            var my_sound:Sound = new Sound();

                            // You can remove this entire block of code in the *********
                            // as it is now only useful in Flash Authoring testing.
                            // I would prefer that you loop the movie from 2 to 16 and have frame 1
                            stop()
                            // and ofter the the if (success) do a gotAndPlay(2). But we can assume that
                            // the sound will have buffered enough by frame 15 to start playing.

                            // **************************************************
                            // if the sound loads, play it; if not, trace failure loading
                            my_sound.onLoad = function(success:Boolean)
                            {
                            if (success) {
                            // my_sound.start(); // Commented out
                            trace("Sound loaded");
                            } else {
                            trace("Sound load failed");
                            }
                            };
                            // **************************************************

                            // load the sound
                            //my_sound.start(15, 0); // Does not apply until loading had started
                            trace (_url.split("/").pop())
                            urlBase = _url.substr(0,_url.lastIndexOf("/")+1)
                            trace (urlBase)

                            my_sound.loadSound(urlBase + "sound/chickychicky.mp3", true);



                            Frame 15:
                            // We can assume that by frame 15 enough sound is buffered to play
                            my_sound.start();


                            --
                            Lon Hosford
                            www.lonhosford.com
                            May many happy bits flow your way!
                            "DPSwebmaster" <webforumsuser@macromedia.com> wrote in message
                            news:e3vgso$6mk$1@forums.macromedia.com...
                            I finally have everything working, but I am having trouble getting the music
                            to
                            delay a certian number of frames before starting.

                            in the AS I tried:

                            var my_sound:Sound = new Sound();
                            // if the sound loads, play it; if not, trace failure loading
                            my_sound.onLoad = function(success:Boolean) {
                            if (success) {
                            my_sound.start();
                            trace("Sound loaded");
                            } else {
                            trace("Sound load failed");
                            }
                            };
                            // load the sound
                            my_sound.start(15, 0);
                            trace (_url.split("/").pop())
                            urlBase = _url.substr(0,_url.lastIndexOf("/")+1)
                            trace (urlBase)

                            my_sound.loadSound(urlBase + "sound/chickychicky.mp3", true);

                            which should play the music beginning on the 15th frame of the animation,
                            correct?

                            the music starts right away and ends before the animation. I am looking to
                            synch the music better with the animtion and I am having some difficulty
                            with
                            this.