Quantcast removeMovieClip() not working? Heres the fix! | The Danosphere.

The Danosphere.

Avatar

class TheDanosphere extends Dan implements Blog

removeMovieClip() not working? Heres the fix!

This problem presented itself while workin on a project for class that required alot of dynamic loading, attachMovies, and so forth. So I’m attaching these movies but for some reason my movieclip.removeMovieClip() calls aren’t doing anything! This problem can be very frustrating as Macromedia / Adobe does little to nothing to document this. The issue is components and the depthManager.

If you have a component in the library (does not need to be on stage!) and try to use _root.getNextHighestDepth() you will get returned a depth in the reserved range. Then when you try to removeMovieClip() the command will fail silently because the clip is out of depth range. As far as I’ve seen this issue only applies to clips who get their depth from _root.getNextHighestDepth()… using getNextHighestDepth() on other clips seems to still work fine. Anyway here is an easy solution I found somewhere:

[actionscript]

function removemovieclip(removemovie:MovieClip) {

var scope = removemovie.parent;
var poorswappedmc = scope.getInstanceAtDepth(0);
poorswappedmc.swapDepths(scope.getNextHighestDepth());
removemovie.swapDepths(0);
removemovie.removeMovieClip();
poorswappedmc.swapDepths(0);

}

[/actionscript]

Simple really- swap the target mc back into the valid depth range and then remove! voila!

Share this post with friends:
  • Twitter
  • Facebook
  • LinkedIn
  • email
  • del.icio.us
  • Digg
  • Reddit
  • Google Bookmarks
  • Mixx
  • StumbleUpon
  • Tumblr

Related Posts

  • Trist

    I don’t know if anyone else has come across this, but I’m not able to remove movie clips that have been added at minus values. Soon as I bring them above zero, normal service is restored.

  • Pedro

    I LOVE YOU! I've been needing something like this so badly

blog comments powered by Disqus

What's Here?