4 Replies Latest reply on Mar 17, 2010 7:56 AM by Will_3

    Help me find syntax error in AS3 code to chain FLV videos.

    Will_3 Level 1

      I posted a how to do this a couple of weeks back & someone was kind enough to offer this advice to an AS newbie...

       

      "you should create a fla, drag an flvplayback component to the stage, create an array of your flvs, initialize an index at zero, assign the flv to start playing your first flv and increment the index in a function that executes when an flv complete and play that array element until all are played.  you'll publish your html and swf from that fla."

       

      And he gave me a code sample which is below... modified to show my "instance" name as FlvChain

      and my flv file names... vid1.flv, vid2.flv, and vid3.flv...

       

      My code...

       

      import fl.video.VideoEvent;

      var flvA:Array=["vid1.flv","vid2.flv","vid3.flv"];

      var index:uint=0;

      FlvChain.source=flvA[index];

      FlvChain.addEventListener(VideoEvent.COMPLETE,completeF){

      index++;

      if(index<flvA.length){

      FlvChain.source=flvA[index];

      } else {

      // all flvs played

      }

      }

       

      When I attempt to Debug I get this message...

       

      "1087: Syntax error: extra characters found after end of program."

       

      I'm sure I made a silly error. I've never done AS before I'm running CS3 & AS3 on a PC with XP Pro.

       

      Thanks for any help.

       

       

       

       

        • 1. Re: Help me find syntax error in AS3 code to chain FLV videos.
          kglad Adobe Community Professional & MVP

          use:

           

          ..

           

          import fl.video.VideoEvent;

          var flvA:Array=["vid1.flv","vid2.flv","vid3.flv"];

          var index:uint=0;

          FlvChain.source=flvA[index];

          FlvChain.addEventListener(VideoEvent.COMPLETE,completeF);

           

          function completeF(e:VideoEvent)

          index++;

          if(index<flvA.length){

          FlvChain.source=flvA[index];

          } else {

          // all flvs played

          }

          }

           

           

           

           

           

          • 2. Re: Help me find syntax error in AS3 code to chain FLV videos.
            Will_3 Level 1

            OK, this works with one little fix...

            you need an open brace at the end of the line with the function call... line 6... to enclose the "body" of the function... like this...

             

            import fl.video.VideoEvent;
            var flvA:Array=["vid1.flv","vid2.flv","vid3.flv"];
            var index:uint=0;
            FlvChain.source=flvA[index];
            FlvChain.addEventListener(VideoEvent.COMPLETE,completeF);
            function completeF(e:VideoEvent){
            index++;
            if(index<flvA.length){
            FlvChain.source=flvA[index];
            } else {
            // all flvs played
            }
            }

             

            Thanks for the help kglad!

            Now one final question... When the vid1.flv ends and vid2.flv starts... and when vid2.flv ends and vid3.flv starts...

            In otherwords each time a new video starts in the chain... there is a "rough spot" and the image switch is not clean.

            You could put all these clips together in a video editor and render them as one big flv... but it would be nice to be able to mix and match them in the Flash presentation.

            Any idea's on how to clean up the switch between videos?

            • 3. Re: Help me find syntax error in AS3 code to chain FLV videos.
              kglad Adobe Community Professional & MVP

              you could use a transition (like a fade) betwen the video changes.

              • 4. Re: Help me find syntax error in AS3 code to chain FLV videos.
                Will_3 Level 1

                Kglad,

                 

                I think the problem is the time it takes for flash to start the next video...

                 

                If you look at the flash player elapsed time bar as one of the videos ends... it turns greenish for a second or so while no video is playing... during the transistion... then the next video starts...

                 

                It's kind of an abrupt interruption so it doesn't make for a smooth transistion or "cut" from one video to the next...

                 

                Since they are seperate flv files... I'm not sure how to create a traditional transistion... like you would do between clips in a video editing program...

                 

                Or maybe I didn't quite understand your answer...

                 

                Thanks for the help !