7 Replies Latest reply on May 25, 2009 5:32 PM by kglad

    my video refuses to stop playing

    javajavabug Level 1

      I thought I was finished building my husbands site when I found a horrible problem.

       

      1) I'm on the portfolio page, and I click a button to load a video.

       

      2) Let's say I change my mind and press "back" button BEFORE the video has a chance to load completely.

       

      3) I am back at the portfolio page. Everything looks okay BUT the video eventually loads. I can't get rid of it if I remain on the portfolio page.

       

      I am using an flv playback component. I am loading the video from a swf.

       

      If anyone has any suggestions, I'd really appreciate it!

       

      Thank you!

        • 1. Re: my video refuses to stop playing
          kglad Adobe Community Professional & MVP

          as2 or as3?  and what do you mean by "..i am loading the video from a swf"?  you're loading a swf into a target movieclip and the swf contains the flvplayback component and the code to load the flv?

          1 person found this helpful
          • 2. Re: my video refuses to stop playing
            javajavabug Level 1

            I am using as3. I included my code; thank you for helping!  (I'm kind of new to Flash and a little embarrassed. I hope my code doesn't totally suck. It's all a learning experience, isn't it!)

             

            Here's my husband's web address; maybe this will help you see problem in action. (Ugh!)  http://www.pmartin.biz

             

            When you go to the portfolio page, click on a video and then select the back button before the video completely loads. If you wait a bit more, the video eventually loads on top of the portfolio page.

             

            If I click on the back button AFTER the video has completely loaded, everything works as it should.

             

            The swf called "reel.swf" contains the video. I load the "reel.swf" into the portfolio page with the code below.


            //Var Demo Reel

            var myPreloader:PreloaderCell = new PreloaderCell();

            var myRequest:URLRequest=new URLRequest("reel.swf");

            var myLoader:Loader = new Loader();


            //Demo Button

            demo.addEventListener(MouseEvent.CLICK, demoClick);

            function demoClick(event:MouseEvent):void {

            gotoAndPlay("demo");


            myLoader.load(myRequest);


            myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);

            function showPreloader(event:Event):void {

            addChild(myPreloader);

            myPreloader.x=418;

            myPreloader.y=352;

            }


            myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);

            function showProgress(event:ProgressEvent):void {

            var percentLoaded:Number=event.bytesLoaded/event.bytesTotal;

            myPreloader.loading_txt.text="Loading - "+Math.round(percentLoaded*100)+"%";

            //myPreloader.bar_mc.width = 198 * percentLoaded;

            }


            myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent);

            function showContent(event:Event):void {

            removeChild(myPreloader);

            addChild(myLoader);

            }

             


            myLoader.alpha=0;


            myLoader.addEventListener(Event.ENTER_FRAME, animate);


            function animate(event:Event):void {

            myLoader.alpha+=.05;

            if (myLoader.alpha>=1) {

            myLoader.alpha=1;

            myLoader.removeEventListener(Event.ENTER_FRAME, animate);

            }

            }


            Code for the back button


            //Back Button

            back.addEventListener(MouseEvent.CLICK, backClick);

            function backClick(event:MouseEvent):void {

            gotoAndPlay("back");

            SoundMixer.stopAll();

            removeChild(myLoader);

            sectionLoader.source = "removeLoader.swf";

             

            }

             

            The "removeLoader.swf" is a blank file that overrides any other swfs that might be loaded.

             

            Thank you!

            • 3. Re: my video refuses to stop playing
              kglad Adobe Community Professional & MVP

              if the video stream is in reel.swf, you need to explicitly stop that stream, unload() your loader and null it after removing it.

               

              if you're publishing for flash 10, you can use unloadAndStop().

              1 person found this helpful
              • 4. Re: my video refuses to stop playing
                javajavabug Level 1

                I'm publishing in Flash Player 9... I'll try 10, and use the  "unloadAndStop();" code. Thanks! What is a "null?" I often get errors with that word.

                 

                Thank you so much again!

                • 5. Re: my video refuses to stop playing
                  kglad Adobe Community Professional & MVP

                  an error mentioning null means you're trying to address some object that doesn't exist.  and i don't think you'll be able to use unloadAndStop() because you can't publish for fp 10.

                  • 6. Re: my video refuses to stop playing
                    javajavabug Level 1

                    Thanks kglad for all of your help. I did a test (although I didn't publish it to the web.) The timeline only had 1 frame.  I made buttons and uploaded my video-swf files. The unloadAndStop did work to stop the video. I did publish to Flash 10.

                     

                    var contentLoader:Loader = new Loader();

                    addChild(contentLoader);

                    reelButton.addEventListener(MouseEvent.CLICK, reel);

                    studioButton.addEventListener(MouseEvent.CLICK, studio);

                    faqButton.addEventListener(MouseEvent.CLICK, faq);

                    function reel(event:MouseEvent):void {

                    loadURL("reel.swf");

                    }

                    function studio(event:MouseEvent):void {

                    loadURL("reelBeast.swf");

                    }

                    function faq(event:MouseEvent):void {

                    loadURL("reelCell.swf");

                    }

                    function loadURL(url:String):void {

                    contentLoader.unloadAndStop();

                    var request:URLRequest = new URLRequest(url);

                    contentLoader.load(request);

                    }

                     

                    Unfortunately, if I was impatient and selected another button before the first video had completely loaded, I had two videos playing. However, I'm really liking this unloadAndStop feature. Thank you for pointing me in this direction. I learned a lot today! I appreciate it!

                    • 7. Re: my video refuses to stop playing
                      kglad Adobe Community Professional & MVP

                      you're welcome.  i didn't realize you had flash cs4.