22 Replies Latest reply on Jul 23, 2011 3:52 AM by Macnimation

    Turn off Audio when external FLV file is closed

    Macnimation Level 1

      Hi,

       

      This is part of my ongoing issue with 6 video files in six Scenes.

       

      I have 6 videos there were imported as enbedded, one in each scene. the first four play but the second two do not. whichever order i place the scenes, it is always the last two that pause at the first frame.

       

      To try another approach, I linked instead to a video externally. This seems to work, but, when I click a button to go to another scene the audio from the previous scene is still playing when the new video starts.

       

      How do I stop the audio playing once I leave the scene so that the next video plays without the other videos audio?

        • 2. Re: Turn off Audio when external FLV file is closed
          relaxatraja Level 5

          You should stop the flvcomponent while moving to next frame, use the stop() method with the instance name of flvComponent:

           

          flvPlayer.stop();

          • 3. Re: Turn off Audio when external FLV file is closed
            Macnimation Level 1

            It is AS3 in Flash CS5

            • 4. Re: Turn off Audio when external FLV file is closed
              Macnimation Level 1

              Where do I place the stop method?

               

              Is it in the button code function that then navigates to the next scene for example?

               

              Lesson1.addEventListener(MouseEvent.CLICK, gotolessonw1);

               

              function gotolessonw1(event:MouseEvent):void
              {
                 
                  MovieClip(this.root).gotoAndPlay(1, "Lesson1");

                  flvPlayer.stop();

               

              }

              • 5. Re: Turn off Audio when external FLV file is closed
                relaxatraja Level 5

                flvplayer is your instance name of flvcomponent which you have on that frame? If yes okay, or otherwise target it properly like mc.flvplayer.stop() like that.

                • 6. Re: Turn off Audio when external FLV file is closed
                  Macnimation Level 1

                  Here is the code used to control the buttons to go to each  video.

                   

                  I have now placed each Video in its own MC and each video is on a frame, so frames 1 to 6 in the Scene Lessons. Each one has a stop command.

                   

                  Thebuttons do go from one to the other now, but the audio still plays from the previous video if I switch to anotehr one, so I could end up with audio from all 6 lessons playing at the same time I i quickly switch form one to the other.

                   

                  so you suggestion is for example use:

                   

                  lesson1.stop();

                   

                  but I do not know where it should be placed?

                   

                   


                  Lesson1.addEventListener(MouseEvent.CLICK, gotolesson1btn);

                   

                  function gotolesson1btn(event:MouseEvent):void
                  {
                     
                      MovieClip(this.root).gotoAndPlay(1, "Lessons");

                   

                  }

                   

                  Lesson2.addEventListener(MouseEvent.CLICK, gotolesson2btn);

                   

                  function gotolesson2btn(event:MouseEvent):void
                  {
                     
                      MovieClip(this.root).gotoAndPlay(2, "Lessons");

                   

                  }

                   

                  Lesson3.addEventListener(MouseEvent.CLICK, gotolesson3btn);

                   

                  function gotolesson3btn(event:MouseEvent):void
                  {
                     
                      MovieClip(this.root).gotoAndPlay(3, "Lessons");

                   

                  }

                   

                  Lesson4.addEventListener(MouseEvent.CLICK, gotolesson4btn);

                   

                  function gotolesson4btn(event:MouseEvent):void
                  {
                     
                      MovieClip(this.root).gotoAndPlay(4, "Lessons");

                   

                  }

                   

                  Lesson5.addEventListener(MouseEvent.CLICK, gotolesson5btn);

                   

                  function gotolesson5btn(event:MouseEvent):void
                  {
                     
                      MovieClip(this.root).gotoAndPlay(5, "Lessons");

                   

                  }

                   

                  Lesson6.addEventListener(MouseEvent.CLICK, gotolesson6btn);

                   

                  function gotolesson6btn(event:MouseEvent):void
                  {
                     
                      MovieClip(this.root).gotoAndPlay(6, "Lessons");

                   

                  }

                   

                   

                   

                  I hope this helps.

                  • 7. Re: Turn off Audio when external FLV file is closed
                    relaxatraja Level 5

                    Make your file according to below first:

                    I hope you are on main timeline with 6 frames and here there is no concept of scenes. so form the layer as say,

                    Layer -> videos > frame1 (mc1), frame2 (mc2), frame3 (mc3), frame4 (mc4), frame5 (mc5), frame6 (mc6)
                    Layer -> Buttons > frame1 (lesson1-lesson6) buttons (extend the frame to 6thframe)
                    Layer -> Actions > code (see below)
                    Where mc1 is the movieclip instance of your video
                    Where lesson1 is the movieclip instance of your button

                    Actions:


                    for (var i:int = 1; i <= 6; i++) {
                        this["lesson" + i].addEventListener(MouseEvent.CLICK, gotolesson);
                    }

                    function gotolesson(e:MouseEvent):void {
                        var tmp:int = int(String(e.target.name).charAt(7))
                        trace("Frame number to go:" + tmp);
                        gotoAndStop(tmp);
                    }

                    I would like to know how you loaded your video, embedded or flvcomponent?

                    • 8. Re: Turn off Audio when external FLV file is closed
                      Macnimation Level 1

                      Hi,

                       

                      The videos are embedded.

                       

                      There is a PNG file that sits in front of the videos that acts as an Interface, and then the six buttons are on top of the Interface.

                       

                      hope this helps.

                      • 9. Re: Turn off Audio when external FLV file is closed
                        relaxatraja Level 5

                        Can you changed the code as I suggested, or send the file by just removing the embedded clips on it so that file size will be low relaxatraja@aol.com

                        • 10. Re: Turn off Audio when external FLV file is closed
                          kglad Adobe Community Professional & MVP

                          if you have no other sound playing while your videos play, you can use:

                           


                           

                           


                          Lesson1.addEventListener(MouseEvent.CLICK, gotolesson1btn);

                           

                          function gotolesson1btn(event:MouseEvent):void
                          {
                              SoundMixer.stopAll();
                              MovieClip(this.root).gotoAndPlay(1, "Lessons");

                           

                          }

                           

                          Lesson2.addEventListener(MouseEvent.CLICK, gotolesson2btn);

                           

                          function gotolesson2btn(event:MouseEvent):void
                          {

                            SoundMixer.stopAll();

                              MovieClip(this.root).gotoAndPlay(2, "Lessons");

                           

                          }

                           

                          Lesson3.addEventListener(MouseEvent.CLICK, gotolesson3btn);

                           

                          function gotolesson3btn(event:MouseEvent):void
                          {

                            SoundMixer.stopAll();

                              MovieClip(this.root).gotoAndPlay(3, "Lessons");

                           

                          }

                           

                          Lesson4.addEventListener(MouseEvent.CLICK, gotolesson4btn);

                           

                          function gotolesson4btn(event:MouseEvent):void
                          {

                            SoundMixer.stopAll();

                              MovieClip(this.root).gotoAndPlay(4, "Lessons");

                           

                          }

                           

                          Lesson5.addEventListener(MouseEvent.CLICK, gotolesson5btn);

                           

                          function gotolesson5btn(event:MouseEvent):void
                          {

                            SoundMixer.stopAll();

                              MovieClip(this.root).gotoAndPlay(5, "Lessons");

                           

                          }

                           

                          Lesson6.addEventListener(MouseEvent.CLICK, gotolesson6btn);

                           

                          function gotolesson6btn(event:MouseEvent):void
                          {

                            SoundMixer.stopAll();

                              MovieClip(this.root).gotoAndPlay(6, "Lessons");

                           

                          }

                           

                           

                           

                           

                          • 11. Re: Turn off Audio when external FLV file is closed
                            Macnimation Level 1

                            ok, I have rebuilt the 6 lessons. I moved them all out of their individual Scenes and but them as MC's on the main timeline as a test.

                             

                            So I have a 15 sec intro video, which goes to an instruction MC and stops. Here the user sees the six buttons and also there is a separate button to start from the first Lesson also like a " start here" which simply goes to Lesson one on the timeline.

                             

                            Each Lesson video is in its own MC and iseach  listed in a single frame on the main timeline.

                             

                            Each Frame has a label: intro, L1 L2 L3 L4 L5 L6

                             

                            Now if I go to Lesson 1 it plays fine the ausio is fine

                             

                            if I then click on Lesson 2, no problem, audio from L1 is off and audio from L2 is on

                             

                             

                            Here is the issue, if I go from intro to Lesson 6, then the video for Lesson 6 plays, but I get audio from ALL 6 lessons at the same time,

                             

                            If I go to any lesson and say skip a few lessons like go from L1 to L4, then I get all audio fro the 4 Lessosn at the same time.

                             

                            Capture.JPG

                             

                            I use the following code on frame intro:

                             

                            stop();


                            instructiontoLesson1.addEventListener(MouseEvent.CLICK, instructiontoLessons);

                             

                            function instructiontoLessons(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                gotoAndPlay("L1");

                             

                            }

                             

                            // This button goes to the Quiz

                             

                            challengebtn.addEventListener(MouseEvent.CLICK, gotochallenge);

                             

                            function gotochallenge(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                MovieClip(this.root).gotoAndPlay(1, "Ready");

                             

                            }

                             

                            Lesson1.addEventListener(MouseEvent.CLICK, gotolesson1btn);

                             

                            function gotolesson1btn(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                gotoAndPlay("L1");  

                             

                            }

                             

                            Lesson2.addEventListener(MouseEvent.CLICK, gotolesson2btn);

                             

                            function gotolesson2btn(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                gotoAndPlay("L2");

                             

                            }

                             

                            Lesson3.addEventListener(MouseEvent.CLICK, gotolesson3btn);

                             

                            function gotolesson3btn(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                gotoAndPlay("L3");

                             

                            }

                             

                            Lesson4.addEventListener(MouseEvent.CLICK, gotolesson4btn);

                             

                            function gotolesson4btn(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                gotoAndPlay("L4");

                             

                            }

                             

                            Lesson5.addEventListener(MouseEvent.CLICK, gotolesson5btn);

                             

                            function gotolesson5btn(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                gotoAndPlay("L5");

                             

                            }

                             

                            Lesson6.addEventListener(MouseEvent.CLICK, gotolesson6btn);

                             

                            function gotolesson6btn(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                gotoAndPlay("L6");

                             

                            }

                             

                            Introduction1.addEventListener(MouseEvent.CLICK, gotoInstruction1btn);

                             

                            function gotoInstruction1btn(event:MouseEvent):void
                            {
                                SoundMixer.stopAll();
                                MovieClip(this.root).gotoAndPlay("intro");

                             

                            }

                            • 12. Re: Turn off Audio when external FLV file is closed
                              kglad Adobe Community Professional & MVP

                              was your code working (except for the sound issue) before?  is so, go back to that version and add the code i suggested.

                              • 13. Re: Turn off Audio when external FLV file is closed
                                relaxatraja Level 5

                                Still my code is not there, okay dont have any idea to send the files with only one embedded clip?

                                • 14. Re: Turn off Audio when external FLV file is closed
                                  Macnimation Level 1

                                  Hi,

                                   

                                  I sent an email to the account you provided.

                                   

                                  I sent you a link to a filesonic account where I uploaded the complete file 53mb. It makes sense for you to see it in full context.

                                   

                                  The whole issue is around the 6 FLV files only so you can ignore the Scenes for the Tests as these work.

                                   

                                  It is the opening Introduction1 scene that has the issue for the moment.

                                   

                                  It contains the 15 sec video intro and then it stops to play a visual intro instruction.

                                   

                                  then the user can go from lesson 1 to 6 in the same timeline.

                                   

                                  Each time I publish an example the result changes.

                                   

                                  I spaced out the frames to see if anything changes because, if I click on LEsson 2, it plays, but if I click on Lesson two again, Lesson 3 plays along with lesson 2.

                                   

                                  Clicking Lesson 3 switches between 3 and 4 and so on.

                                   

                                  Totally confusing for me. Whe nyou see the project you will see why it is important to fix this issue. It is not the final content yet, but it will chnage once the navigation issue is resolved.

                                   

                                  I have googled hi and lo for a week and it does seem to be a common issue over the years with Flash.

                                   

                                  I hope this helps.

                                  • 15. Re: Turn off Audio when external FLV file is closed
                                    Macnimation Level 1

                                    using the SoundMixer function does not seem to work.

                                     

                                    Everytime I publish the same file I get different results though.

                                     

                                    if you have a private email account I can also send you the link to look at the files?

                                     

                                    thanks for all your help.

                                    • 16. Re: Turn off Audio when external FLV file is closed
                                      relaxatraja Level 5

                                      Okay! Let I will look into that

                                      • 17. Re: Turn off Audio when external FLV file is closed
                                        Macnimation Level 1

                                        Hi, did you manage to look at the file?

                                         

                                        I removed the Lesson 1 FLV completely and replaced it with screenshots in the timeline with the audio layer above it. So instead of the MC containing the FLV file the MC has images timed throught the timeline to change correctly with the Audio.

                                         

                                        It looks exactly the same as the FLV, but, the issue still exists, so I as assuming it is down to the Audio instead of it being an FLV issue?

                                         

                                        I go from lesson 1 to lesson 6 one at a time and no problem.

                                         

                                        It is only when I go to random lessons that all of the audio starts together from all 6 lessons.

                                        • 18. Re: Turn off Audio when external FLV file is closed
                                          relaxatraja Level 5

                                          Mostly the both method are same, I looked at your file and the structure you made is little bit different so many duplication of same frame for different purpose. I would like is not a good strategy to follow. I need to spend time on your file to restructure. So kindly apalogize for that. I will look into that in my free hours.

                                          • 20. Re: Turn off Audio when external FLV file is closed
                                            Macnimation Level 1

                                            Hi,

                                             

                                            I'll take a look later as that site is blocked by our network.

                                             

                                            Apologies for the unusual approach to the structure.

                                             

                                            I come from an animation/cartoon background and I'm use to using Flash for creating cartoon episodes etc.. and so using Scenes for Camera cuts and Scene changes is the norm at times.

                                             

                                            It was basically built as I went along as I needed to do something, rather than sitting back and deciding on the correct structure.

                                             

                                            Anyway I'll take a look later.

                                             

                                            Thank very much for the time and effort.

                                            • 21. Re: Turn off Audio when external FLV file is closed
                                              Macnimation Level 1

                                              Hi,

                                               

                                              thanks for the code chnages it indeed stops the audio from continuing when switching from Lesson to Lesson.

                                               

                                              The only issue left now, is that, clicking on the Continue Button to leave the lessons and start the challeneg Questions cuases ALL 6 lesson uadio to play at the same time.

                                               

                                              I tried adding the SoundMixer.stopAll();

                                               

                                              function to that button but it makes no difference.

                                               

                                              any ideas?

                                               

                                              Cheers

                                              • 22. Re: Turn off Audio when external FLV file is closed
                                                Macnimation Level 1

                                                I fixed that issue with a code tweek to correct it to your code.

                                                 

                                                I remove all the Lessons buttons and only left one button that will return the user to the main Lessons page to simply the Interface.

                                                 

                                                The only issue left now, and this is the final problem as I have updated and changed the button code to go to the Test questions, and everything works fine now, is:

                                                 

                                                When I click the button to got to Lesson One from another scene, All the audio of all 6 movies plays again.

                                                 

                                                cheers