15 Replies Latest reply on Sep 6, 2010 10:33 AM by kglad

    Remember movie

    huray Level 1

      I have an empty container to open another SWF. I close and open this SWF again, it plays from the beginning. I want it to remember where I close just now so that I can continue viewing. Need help.

        • 1. Re: Remember movie
          kglad Adobe Community Professional & MVP

          you're using as2 and your loading a swf into a target movieclip?

           

          and, at some point, you're unloading that swf and want to record that loaded swf's last main timeline frame and when that swf is reloaded, start from that recorded main timeline frame?

          • 2. Re: Remember movie
            huray Level 1

            absolutely correct.

            • 3. Re: Remember movie
              kglad Adobe Community Professional & MVP

              add an enterframe loop that repeatedly checks the _currentframe of your loaded swf's load-target movieclip and store that value in a variable that you check when loading of your swf is compete.  

               

              if you use a moviecliploader, that would look something like:

               

              var cf:Number = 0;
              var mcl:MovieClipLoader = new MovieClipLoader();
              var lo:Object = {};
              lo.onLoadInit=function(target:MovieClip){
              if(cf){
              target.gotoAndPlay(cf);
              }
              counterMC.onEnterFrame=function(){
              cf=target._currentframe;
              }
              }
              }

               

              and when you remove/unload your swf, delete counterMC.onEnterFrame.

              • 4. Re: Remember movie
                huray Level 1

                It won't work.

                This is the script that I put in same frame in the fla used to open Untitled-2.swf. May be you would point out which part goes wrong.

                 

                stop();
                var mcLoader:MovieClipLoader = new MovieClipLoader();
                mcLoader.addListener(loadListener);

                 

                var mc1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
                mcLoader.loadClip("Untitled-2.swf", "mc");

                 

                 

                 

                on (press) {gotoAndStop(1);

                 

                unloadMovie(mc);
                }

                 

                 


                var cf:Number = 0;
                var mc1:MovieClipLoader = new MovieClipLoader();
                var lo:Object = {};
                lo.onLoadInit=function(target:MovieClip){
                if(cf){
                target.gotoAndPlay(cf);
                }
                counterMC.onEnterFrame=function(){
                cf=target._currentframe;
                }
                }

                • 5. Re: Remember movie
                  kglad Adobe Community Professional & MVP

                  use:

                   


                   

                  var cf:Number = 0;
                  var mcl:MovieClipLoader = new MovieClipLoader();
                  var lo:Object = {};
                  lo.onLoadInit=function(target:MovieClip){
                  if(cf){
                  target.gotoAndPlay(cf);
                  }
                  counterMC.onEnterFrame=function(){
                  cf=target._currentframe;
                  }
                  }
                  }

                   

                  mcl.addListener(lo);

                  var mc1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
                  mcl.loadClip("Untitled-2.swf",mc1);

                   

                   

                  yourbtn.onRelease=function(){

                  gotoAndStop(1);

                  mcl.unloadClip(mc1);

                  delete counterMC.onEnterFrame;
                  }

                  • 6. Re: Remember movie
                    huray Level 1

                    I still can't get it done.

                    I have 2 swf, swf A and swf B. I use swf A to open swf B.

                    I put the following scripts into frame 2 of swf A fla.

                     

                    var cf:Number = 0;
                    var mc1:MovieClipLoader = new MovieClipLoader();
                    var lo:Object = {};
                    lo.onLoadInit=function(target:MovieClip){
                    if(cf){
                    target.gotoAndPlay(cf);
                    }
                    counterMC.onEnterFrame=function(){
                    cf=target._currentframe;
                    }
                    }

                     

                    mcl.addListener(lo);

                     

                    var mc1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
                    mcl.loadClip("Untitled-2.swf",mc1);

                     

                    yourbtn.onRelease=function(){

                    gotoAndStop(1);

                    mcl.unloadClip(mc1);

                    delete counterMC.onEnterFrame;}

                     

                    swf A stop at frame 1 when loaded. There is a button in frame 1 to go to frame 2 on press. Swf B is loaded in frame 2. There are 5 frames in fla of

                    swf B. While swf B is playing , yourbtn is press to go to frame 1. I press yourbtn when swf B played at frame 3. I press the button in frame 1 of swf A to go to frame 2 to load swf B again, swf B is loaded but plays from the begining, not fron frame 3 as I unloaded. Fps of swf A and swf B are the same.

                    Something must be wrong.

                    • 7. Re: Remember movie
                      kglad Adobe Community Professional & MVP

                      does counterMC exist?

                      • 8. Re: Remember movie
                        huray Level 1

                        Yes, a movie clip with an name counterMC.

                        • 9. Re: Remember movie
                          kglad Adobe Community Professional & MVP

                          use the trace() function to pinpoint the error.

                          • 10. Re: Remember movie
                            huray Level 1

                            trace counterMC: output _levelo.counterMC

                            trace mc1: output _level0.mc

                            trace cf: output 0

                            trace lo: output [object Object]

                            • 11. Re: Remember movie
                              kglad Adobe Community Professional & MVP

                              copy and paste anything from flash that you want to communicate.   it's misleading when you don't and you're sloppy.

                               

                              copy and paste the code from your fla that you're using in frame 2 of your main swf.

                              • 12. Re: Remember movie
                                huray Level 1

                                var cf:Number = 0;

                                 

                                var mc1:MovieClipLoader = new MovieClipLoader();

                                 

                                var lo:Object = {};

                                 

                                lo.onLoadInit=function(target:MovieClip){

                                 

                                if(cf){

                                 

                                target.gotoAndPlay(cf);

                                 

                                }

                                 

                                counterMC.onEnterFrame=function(){

                                 

                                cf=target._currentframe;

                                 

                                }

                                 

                                }

                                 

                                mcl.addListener(lo);

                                 

                                var mc1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
                                mcl.loadClip("Untitled-2.swf",mc1);

                                 

                                 

                                 

                                yourbtn.onRelease=function(){

                                 

                                gotoAndStop(1);

                                 

                                mcl.unloadClip(mc1);

                                 

                                delete counterMC.onEnterFrame;
                                }
                                • 13. Re: Remember movie
                                  kglad Adobe Community Professional & MVP

                                  and what's the name of the swf you're loading?

                                  • 14. Re: Remember movie
                                    huray Level 1

                                    Untitled-2

                                    • 15. Re: Remember movie
                                      kglad Adobe Community Professional & MVP

                                      make sure your loading swf is not untitled.  then try the following:

                                       

                                      var cf:Number = 0;

                                      var tl:MovieClip = this;

                                       

                                      var mc1:MovieClipLoader = new MovieClipLoader();

                                       

                                      var lo:Object = {};

                                       

                                      lo.onLoadInit=function(target:MovieClip){

                                       

                                      if(tl.cf){

                                       

                                      target.gotoAndPlay(cf);

                                       

                                      }

                                       

                                      counterMC.onEnterFrame=function(){

                                       

                                      tl.cf=target._currentframe;}

                                       

                                      }

                                       

                                      mcl.addListener(lo);

                                       

                                      var mc1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
                                      mcl.loadClip("Untitled-2.swf",mc1);

                                       

                                       

                                       

                                      yourbtn.onRelease=function(){

                                       

                                      gotoAndStop(1);

                                       

                                      mcl.unloadClip(mc1);

                                       

                                      delete counterMC.onEnterFrame;
                                      }