title: AS3 How to remove previous loaders
body: <p>In Flash CS4, I'm creating a photo gallery. My goal is to load different thumbnails from a number of images. I have managed that when one clicks an image, a number of thumbnails are being displayed, but when one clicks another image, the new thumbnails are placed on top of the old ones. Can someone help me on how to get rid of the old thumbnails?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>for (var i:int = 0; i &lt; thumbnails.length(); i++) {
    imgLoader.unload();
    imgLoader = new Loader();
    imgLoader.load(new URLRequest(thumbnails[i]));
    imgLoader.name= i;
    imgLoader.x =  95 * columns;
    imgLoader.y = 80 * rows;
    imgLoader.alpha = 0;
    details.gallery.addChild(imgLoader);
  
    if (columns+1&lt; 5) {
      columns++;
    } else {
      columns = 0;
      rows++;
    }
  }
  </code></pre>