Skip to main content
Inspiring
January 12, 2011
Answered

unloading a movie clip

  • January 12, 2011
  • 1 reply
  • 580 views

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?

This topic has been closed for replies.
Correct answer kglad

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

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 12, 2011

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

landarAuthor
Inspiring
January 13, 2011

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
{
    clearInterval(timer_int);
}

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

    _root.schedImage.schedTreeDestructor();
    mcl.unloadClip(_root.schedImage);

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

kglad
Community Expert
Community Expert
January 13, 2011

or you can clear the interval directly:

clearInterval(_root.schedImage.timer_int);