7 Replies Latest reply on Mar 14, 2011 4:05 PM by pbesong

    timing audio/video in Flash

    pbesong Level 1

      I have a Flash animation that starts with an audio clip imported. When that's done it goes to a video. After that another audio clip plays, but I can't get it to start when it's supposed to. It keeps coming in too early even though its keyframe is after the movie ends. In fact I had to move the audio's keyframe about 1500 frames past where it should be to get it to come in at the right time. My Flash movie is 24 FPS. The .mov file being referenced in the FLVPlayback is 23.98 FPS. What's going on here?

        • 1. Re: timing audio/video in Flash
          somascope Level 3

          How are you using audio in Flash? Did you import it into the FLA file and put it into the timeline? If so, is the properties panel saying it is "event" or "streaming"? It should be "streaming", which ensures that your timeline and the audio track are in synch.

           

          Is the audio exiting on the timeline, and when you see the audio visually ending, is this where you place an instance of the video player?

          • 2. Re: timing audio/video in Flash
            pbesong Level 1

            Audio is set to streaming so I can see the waveform. Since I couldn't see the waveform for the video, I temporarily put just the audio track from the video in at the same point where the video starts so I could see visually where it ends. Then prior to compiling, I removed that audio clip. The second audio clip should come immediately after the movie, but when I put it there, it comes about halfway thru the video, which doesn't make any sense. I had to move it downstream 1500 frames to get it to come in at the right time. The graphics that go along with the second audio are in the right spot right after the video and come up as they should.

            • 3. Re: timing audio/video in Flash
              somascope Level 3

              There is a better way to synch the ending of audio/video clips, rather than relying on spreading out your timeline with multiple frames (which can lead to this problem you are having).

               

              Instead of using frames, that you think match up o the length of your video, to determine what you'd start audio, instead you should use AS3 code. Start with giving your FLVPlayback instance a name, like "videoPlayer". And when we see the video player, be sure the timeline is NOT playing - it should be stopped. Then add this code:

               

              videoPlayer.addEventListener(VideoEvent.COMPLETE, doNext);// This calls a function when the video reaches its end

              function doNext(e:VideoEvent):void{

                 gotoAndPlay("audioClip2");//This is the frame label, which you should add, where your 2nd audio clip would begin playing

              }

              • 4. Re: timing audio/video in Flash
                pbesong Level 1

                Thanks, somascope. a script may be the best answer here. I'll give it a try when I get a chance.

                • 5. Re: timing audio/video in Flash
                  pbesong Level 1

                  I finally got a chance to try this, but keep getting an error:

                   

                  "1046: Type was not found or was not a compile-time constant: VideoEvent."

                   

                  Where would I put the stop() for the timeline, where the movie starts? Where would your code go? I tried both the beginning frame of the movie and the last frame and kept getting the above error.

                  • 6. Re: timing audio/video in Flash
                    somascope Level 3

                    We need to have you import the class for the VideoEvent:

                     

                    import fl.video.VideoEvent;

                    stop();

                    videoPlayer.addEventListener(VideoEvent.COMPLETE, doNext);// This calls a function when the video reaches its end

                    function doNext(e:VideoEvent):void{

                       gotoAndPlay("audioClip2");//This is the frame label, which you should add, where your 2nd audio clip would begin playing

                    }

                     

                    Make sure this code exists in the same frame as does the instance of the FLVPlayback component (but on its own layer, named Actions or something). So if the component exists on frame 80, so should this code.

                    • 7. Re: timing audio/video in Flash
                      pbesong Level 1

                      That worked perfectly. Thanks so much, somascope!!!