3 Replies Latest reply on Jan 13, 2011 7:07 AM by kglad

    unloading a movie clip

    landar Level 1

      I can load and unload a movie via the "loadClip" and "unloadClip" methods. So far, so good. However, I notice that the movie is not altogether "unloaded".

      Some of it continues to run even though the visible movie is gone. I know this because there is an "interval" timer started within the movie and I am seeing the effects of that "thread" (ok, maybe its not a thread but thats what it seems like to me. Process, maybe?). Anyway, even though I have used the unloadClip method to unload the clip, I have a feeling that there is a lot more I should be doing to clean up the mess I have left behind. Seeing the effects of the still-running interval timer, I now have visions of memory leaks not far behind.


      So, the question: What must one do to really kill off a movie clip? Make it appear to have never existed within the player? Clean slate?

        • 1. Re: unloading a movie clip
          kglad Adobe Community Professional & MVP

          use removeMovieClip() applied to the load-target or explicitly stop all streams and loops in the loaded swf.

          • 2. Re: unloading a movie clip
            landar Level 1

            Thanks for the response Kglad. I tried the removeMovieClip() method but no success.


            I did, however, get the issue resolved by clearing the interval just before unloading the clip.


            I also found this thread which was very helpful -> http://forums.adobe.com/message/610611#610611


            So it seems that any interval timer or event handler set up in a movie needs to be specifically removed before the movie is unloaded. Here is what I did:


            Create a function within the loaded movie itself to handle the interval timer (timer_int). I called it:


            function schedTreeDestructor()    //kills any timer process that is running. Called prior to unloading the clip, else timer keeps going


            Then, in the main movie, just before unloading the movie clip(which is called schedImage), I call the function like so:




            No more interval timer running. Kinda crude, (me thinks) but it works.

            • 3. Re: unloading a movie clip
              kglad Adobe Community Professional & MVP

              or you can clear the interval directly:




              1 person found this helpful