7 Replies Latest reply on Feb 16, 2011 12:18 AM by moccamaximum

    Working with linked video files in Flash CS5

    AzzyDude24601

      Hi,

       

      I'm working on a project that involves making decisions that affect how a short film plays out.

       

      The basic idea is link some video files to the flash file (don't embed because it loses a lot of quality) and have buttons appear at the end of each clip that will link to another place on the timeline where another video clip will play. Pretty simple.

       

      However one problem I have encountered is the only way I can make the buttons appear after the video is finished, is by dragging out the single frame of video on the timeline to whatever length in seconds it is multiplied by the number of frames per second.

       

      This is very tedious and not very effective despite solving the problem.

       

      Is there some way to maintain each linked clip in a single frame and only move to the next frame (which contains the relative buttons) after the video is finished?

       

      Of course if there is an even more effective way to do this please let me know as well.

       

      Thanks,

       

      Aaron

        • 1. Re: Working with linked video files in Flash CS5
          moccamaximum Level 5

          I´m assuming you use a flvPlayback Component that you have placed on stage?

          This component has a property that is called "fullScreenTakeOver", and that is per default set to true, so whenever you play a video in fullscreen mode it will automatically move in front of all other objects on stage, even Buttons and MovieClips that are originally positioned in front of the component. You can`t set that property in the component inspector, you have to name your player component and then in the code you say:

           

          player_name.fullScreenTakeOver = false;

           

          That should prevent the buttons from vanishing

          1 person found this helpful
          • 2. Re: Working with linked video files in Flash CS5
            AzzyDude24601 Level 1

            That is true, I am using a flvPlayback Component. Thank you for your answer.

             

            However how does this solve my problem of my buttons appearing at the right time? The issue is when the buttons are visible all the time, the user can just skip through all the videos just by clicking through all the buttons and make no decisions.

             

            I want it to they can't see any buttons until the end when the video clip pauses and they make their decision?

            • 3. Re: Working with linked video files in Flash CS5
              moccamaximum Level 5

              What you really want have is this:

               

              Instead of using the timeline you should use Code to organize your application.

               

              So you will have only one frame and only one scene and only one flvComponent.

               

               

              import fl.video.FLVPlayback;
              import fl.video.VideoEvent;

               

              //Assuming you have 9 Videosegments to choose from

               

              var videoNr:uint = 9;

               

              // the buttons to navigate to the segments

               

              for (var i:uint=0; i<videoNr;i++){

                 var currentButton:String = "btn_"+i;

                this[currentButton].addEventListener(MouseEvent.CLICK, playSegement);

              }

               

               

              // the array to store the names of the videosegments

               

              var videoArray:Array = new Array();

               

              for (var i:uint=0; i<videoNr;i++){

                var currentVideo:String = "video_"+i+".flv";

                videoArray.push(currentVideo);

              }

               

              //hide the buttons whenever the video plays and vice versa

               

              flvPlayer.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, hideButtons);

              flvPlayer.addEventListener(VideoEvent.STOPPED_STATE_ENTERED, showButtons);
              flvPlayer.fullScreenTakeOver = false;

               

              function hideButtons(e:VideoEvent):void{

              for (var i:uint=0; i<videoNr;i++){

                 var currentButton:String = "btn_"+i;

                this.getChildByName(currentButton).visible = false;

              }

              }

               

              function showButtons(e:VideoEvent):void{

              for (var i:uint=0; i<videoNr;i++){

                 var currentButton:String = "btn_"+i;

                this.getChildByName(currentButton).visible = false;

              }

              // or make a switch clause where you define which buttons are visible after which segment

               

              //switch(i){

              //only 1 and 2 are visible after Segmenet 0 has played

              //case 0: this.getChildByName("btn_1").visible = true;this.getChildByName("btn_2").visible = true;break;

              //only 3 and 4 are visible after Segment 1 has played

              //case 1:  this.getChildByName("btn_3").visible = true;this.getChildByName("btn_4").visible = true;break;

              //}

              }

               

               

              //function to choose from the videos

               

              function playSegment(e:MouseEvent):void{

                var whichButton:String = e.currentTarget.name.substr(4,1);

                //gives the IndexNr of the Video that should play

                flvPlayer.source = videoArray[uint(whichButton)];

                flvPlayer.autoplay = true;

              // you want the actual video to stop on the last frame

                 flvPlayer.autorewind = false;

              }

              1 person found this helpful
              • 4. Re: Working with linked video files in Flash CS5
                AzzyDude24601 Level 1

                Thanks for your help. I'm working with the code now.

                 

                Could you tell me how each button corresponds to the correct video clip we want to play?

                 

                I think the answer's in the switch clause but I can't quite get my head around it...

                 

                I have my 3 test videos labled video_1.flv, video_2.flv etc. and my buttons are btn_1, btn_2 etc.

                • 5. Re: Working with linked video files in Flash CS5
                  AzzyDude24601 Level 1

                  Also, on this line:

                   

                  for (var i:uint=0; i<videoNr;i++){

                   

                  I am getting an error message saying

                   

                  Scene 1, Layer 'Layer 1', Frame 1, Line 38    1151: A conflict exists with definition i in namespace internal.

                   

                  Any idea why?

                  • 6. Re: Working with linked video files in Flash CS5
                    moccamaximum Level 5

                    on the higher level the i var already exists

                     

                    for (var i:uint=0; i<videoNr;i++){

                      var currentVideo:String = "video_"+i+".flv";

                      videoArray.push(currentVideo);

                    }

                     

                    so either give it another name or plug it inside a function

                     

                    like so:

                     

                    setVideoPaths();


                    function setVideoPaths():void{

                    for (var i:uint=0; i<videoNr;i++){

                      var currentVideo:String = "video_"+i+".flv";

                      videoArray.push(currentVideo);

                    }

                    }

                     

                    same goes for the buttons

                    • 7. Re: Working with linked video files in Flash CS5
                      moccamaximum Level 5

                      the substring Function I use to evaluate e.currentTarget makes nothing else than looking for the number that is appended after the underscore, so its a good idea to keep the buttons name index synchron to the movie you want to play (btn_1>video_1, etc.), if you have more than 9 videosegments you will have to add an additional if-clause that first looks for the length of e.currentTarget`s name (is it 5 like in btn_1 or 6 like in btn_10), building the video_array that an arrays index always starts with 0, so put an empty string inside your video_array first, that way it looks like ["","video_1.flv", etc...].