1 Reply Latest reply on Dec 26, 2006 12:18 PM by kglad

    dynamic movie clip removal

    Level 1
      I'm working on a Flash/XML photo album that loads image thumbnails dynamically by creating individual movie clips for each thumbnail. The thumbnails are divided into 10 groups. Every time a new group of thumbnails is selected from the album the XML array is upadated with the correspondig image file name and path. The only problem is that since there are different number of photos in each thumbnail group the extra image_mc's created dynamically remain, even if they are not from the specific group. For example for group 1 I have 6 thumbnail images, group 2 contains 4 thumbnail images. If I start with group 1 and then select group 2, the 4 thumbnails from group 1 are displayed plus number 5 and 6 from the previous group. What's the best way to remove all the image_mc's created dynamically before each new thumbnail load. This is what I have so far and it doesn't work:

      // thumbnails is the array
      function thumbDisplay(thumbnails){
      var galleryLength:Number = thumbnails.length;
      removeMC();
      // loop through each of the images in the gallery_array.
      for (var i = 0; i<galleryLength; i++) {
      /* create a movie clip instance which holds the image, also set a variable,
      thisMC, which is an alias to the movie clip instance. */
      thisMC = this.createEmptyMovieClip("image"+i+"_mc", i);

      /* load the current image source into the new movie clip instance,
      using the MovieClipLoader class. */
      mcLoader_mcl.loadClip("photos/"+selectedGallery+"/thumbs/"+thumbnails ,thisMC);


      function removeMC():Void{
      for(var i=0; i<thumbnails.length; i++){
      thisMC.removeMovieClip("image"+i+"_mc");
      }
      }


      Any help would be great. Thanks.