7 Replies Latest reply on Dec 25, 2009 8:16 AM by kglad

    timeline sound isn't skipped

    jiggy1965 Level 1

      To make a preloader work on frame 1 I can't use 'export to first frame' on a library sound file. This would mess up my preloader. So I deselected that option and instead dragged the sound file (with 'export for actionscript' still selected) to frame 2. Frame 1 would include the preloader part but for testing purposes I just placed gotoAndPlay(3) there. This would immediately skip frame 2 (with the sound file) and continue from frame 3. Frame 3 would later be the start for the main movie. But for now I just placed this code:

       

      var my_sound:Sound = new Sound();
      my_sound.attachSound("soundfile.mp3");
      my_sound.start();

       

      Testing the movie I found out that the sound played twice on top of each other. So I replaced above code with comment lines:

       

      //var my_sound:Sound = new Sound();
      //my_sound.attachSound("soundfile.mp3");
      //my_sound.start();

       

      That's how I found out that although frame 2, with the sound part, should be skipped, it is played nevertheless. How is this possible when frame 1 skips frame 2 right away with a gotoAndPlay(3)? Frame 2 is never reached, so how come the sound is playing anyway? I wanted to use this method to export the sound file to frame 2. Placing it on frame 2 while skipping it should make it play, but loaded nevertheless. So that later on I could use attachSound to have it play at a later time.

       

      Anyone who can explain why the sound is playing when it shouldn't? See attached file.

        • 1. Re: timeline sound isn't skipped
          kglad Adobe Community Professional & MVP

          your sound probably is set to stream.  assign it to an event sound if you don't want it to play if the starting frame is skipped.

          • 2. Re: timeline sound isn't skipped
            jiggy1965 Level 1

            No, it's set to Event. The only way I can get it to work is to set it to Stop. Or... shift frame 1, 2 and 3 one frame to the right. The first frame now being empty, frame 2 now containing gotoAndPlay(4), frame 3 the sound bit, frame 4 the main movie. Then the sound IS being skipped. Like it should.

             

            So I'm curious, why doesn't it work when all of this starts from frame 1 (sound is playing when it should be skipped), but it does work (sound being sipped) when these frame start anywhere BUT frame 1?

            • 3. Re: timeline sound isn't skipped
              kglad Adobe Community Professional & MVP

              if the sound is an event sound it will only play if you're playing the frame where your sound starts or, you're doing something else to start your sound (like not waiting until frame 3 has loaded to execute that goto).

              • 4. Re: timeline sound isn't skipped
                jiggy1965 Level 1

                If you download my attached file from post #1 you can see that I haven't done anything that would make that sound play.

                 

                Frame 1 has gotoAndPlay(3), frame 2 is a frame with the library's sound dragged on stage, frame 3 has only three commented lines, all other are empty. Yet the sound from frame 2 is playing even if it is skipped by frame 1.

                 

                Can you check out the file?

                • 5. Re: timeline sound isn't skipped
                  kglad Adobe Community Professional & MVP

                  as mentioned above, you're not waiting until frame 3 has loaded to execute that goto.

                  • 6. Re: timeline sound isn't skipped
                    jiggy1965 Level 1

                    I'm sorry, but I don't quite understand what you mean. When I start the swf, on frame 1 it says gotoAndPlay(3). If I understand you correctly flash would first go through all available frames (loading them in memory) and after all frames/bytes have loaded begin from frame 1? That doesn't make sense to me. That would mean flash would first show all images, execute all commands if finds in every frame while loading each frame, before (after all frames have been loaded), starting from frame 1 and execute all commands properly. But perhaps you mean something else?

                     

                    A simple test would be in frame 1:

                    stop();

                    gotoAndPlay(3);

                     

                    Still the sound in frame 2 is playing even though I'm waiting with the stop-command.

                     

                    And when I shift frame 1-2-3 to 2-3-4 it does work (sound is skipped). So it has something to do with how flash handles frame 1 I think?

                    • 7. Re: timeline sound isn't skipped
                      kglad Adobe Community Professional & MVP

                      flash displays and executes the code in frame 1 as soon as the assets needed in frame 1 are loaded.  that can be (and is, in your file) BEFORE the assets needed by frame 3 are loaded.

                       

                      so, flash cannot go to and play frame 3 when your code in frame 1 executes.   therefore, your swf will be played just as if that code didn't exist (except code in frame 2 won't execute).