View Single Post
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator 17 Creative Assets 2006-11-04 #2 Old  
001 - Delete all Movie Clips on a Timeline
 
If you ever need to remove all of the movie clips on a timeline you could use the following function. Keep in mind that this will only remove movie clips that have been added using attachMovie, createEmptyMovieClip, or duplicateMovieClip.

ActionScript Code:
  1. function removeChildren(parent:MovieClip):Void {
  2.     var i:String;
  3.     for (i in parent) {
  4.         if (parent[i].removeMovieClip) {
  5.             parent[i].removeMovieClip();
  6.         }
  7.     }
  8. }
  9.  
  10. // Delete all of the movie clips in myMovieClip.
  11. removeChildren(myMovieClip);
Instead of using typeof to check if the object is a movie clip I am simply checking if the removeMovieClip method is available in the object. This should be quicker than using typeof.