6 Replies Latest reply on Mar 31, 2011 8:29 AM by Kents79

    Pausing a movieclip - Part 2

    Kents79 Level 1

      Hi

       

      I need a little help with the code below. This is the predicament I’m in.

       

      I have 3 files:

       

      Launch.exe

      video.swf

      pause.swf

       

      In the launch.exe, I have a ‘loadmovie’ command which loads the external file ‘video.swf’.

      When the video is loaded, I want the viewer to be able to hit the SPACEBAR at any time which will result in pausing the video (pause.swf appears on screen) and after 3 seconds unloads the video.swf file and jumps to a frame label on the ‘Launch.exe’ timeline.

       

      The code below is what I have at the moment but it doesn’t work.

       

      Anybody have any suggestions?

       

       

      pause_icon._visible = false;

       

      var keyListener:Object = new Object();

      Key.addListener(keyListener);

       

      keyListener.onKeyUp = function(){

          if(Key.getCode() == 32){  // SPACE key

                video_ad.stop();  // substitute your movieclip name

                pause_icon._visible = true;

                var sto = setTimeout(moveAlong, 3000);

                                        loadMovie("assets/pause.swf", 95);

       

          }

      }

       

      function moveAlong(){

           pause_icon._visible = false;

                      _root.myExternalSWF.gotoAndStop ("home_promotions");

           unloadMovie(90);

       

      }

        • 1. Re: Pausing a movieclip - Part 2
          kglad Adobe Community Professional & MVP

          1.  is video_ad the target movieclip for the loadMovie() method used to load video.swf?

           

          2.  if you're going to load a swf into a level, you should use loadMovieNum().

           

          3.  you're not unloading video.swf

          • 2. Re: Pausing a movieclip - Part 2
            Kents79 Level 1

            Yes, 'video_ad' is the target movieclip I need to pause.

            And yes, when the 3 seconds are up after the pause........it should unload the video.swf and on the launch.exe; it should jump to the label ' home_promotions'

            • 3. Re: Pausing a movieclip - Part 2
              kglad Adobe Community Professional & MVP
              var tl:MovieClip=this;

              pause_icon._visible = false;

               

              var keyListener:Object = new Object();

              Key.addListener(keyListener);

               

              keyListener.onKeyUp = function(){

                  if(Key.getCode() == 32){  // SPACE key

                        video_ad.stop();  // substitute your movieclip name

                        pause_icon._visible = true;

              clearTimeout(sto);

                        var sto = setTimeout(moveAlong, 3000);

                                                loadMovieNum("assets/pause.swf", 95);

               

                  }

              }

               

              function moveAlong(){

                   pause_icon._visible = false;

              video_ad.swapDepths(tl.getNextHighestDepth())

              video_ad.removeMovieClip();

                              _root.myExternalSWF.gotoAndStop ("home_promotions");  // <-don't know about this

                   unloadMovieNum(95);

                pause_icon._visible=false;  // ?

              tl.gotoAndStop("yourlabelonthistimeline");

              }

              • 4. Re: Pausing a movieclip - Part 2
                Kents79 Level 1

                When I put that code in. the movieclip does not play in my video.swf file.

                Also, the 'pause.swf' is visable when the video.swf loads.

                 

                Also, when you hit the SPACEBAR, it doesn't jump to the label of the parent swf (launch.exe)

                • 5. Re: Pausing a movieclip - Part 2
                  kglad Adobe Community Professional & MVP

                  then:

                   

                  1.   you have other code causing pause.swf to load

                  2.   what's the point of pause_icon?

                  3.  you've failed to label that main timeline frame or that timeline is out of scope of the code.

                  4.  what movieclip in video.swf?

                  1 person found this helpful
                  • 6. Re: Pausing a movieclip - Part 2
                    Kents79 Level 1

                    Ok, I'm going to go back to the way you showed me first.  By having the 'movieclip' video on the main timeline of my 'launch.exe' file instead of loading an external swf (video.swf).

                     

                    This way works perfectly except for one thing.

                     

                    When the playhead jumps to the framelabel "home_promotions" and go to another scene; the pause icon appears again and it jumps you back to the framelabel "home_promotions".

                     

                    It's as if the script is still running in the background.

                     

                     

                     

                    pause_icon._visible = false;

                     

                    var keyListener:Object = new Object();

                    Key.addListener(keyListener);

                     

                    keyListener.onKeyUp = function(){

                        if(Key.getCode() == 32){  // SPACE key

                              video_ad.stop();  // substitute your movieclip name

                              pause_icon._visible = true;

                              var sto = setTimeout(moveAlong, 3000);

                                loadMovie("pause.swf", 30);

                     

                        }

                    }

                     

                    function moveAlong(){

                         pause_icon._visible = false;

                         gotoAndStop("home_promotions");

                          unloadMovie(30);

                     

                    }