title: dynamically create a MovieClip in AS2 in a Loop
body: <p>I try to add a MovieClip with every loop.</p>
  
  <p>But my script overwrite every MC except for the last one.</p>
  
  <p>I have to use AS2</p>
  
  <pre><code>var myXML:XML = new XML();
  myXML.ignoreWhite=true;
  myXML.load("config.xml");
  myXML.onLoad = function(success){
  
      if (success){
          var images = myXML.firstChild.childNodes;
  
          for (i = 0; i &lt;  images.length; i++) {
              var imageNumber = i+1;
              var imageValue = images[i].firstChild.nodeValue;
              var imageName = "image"+imageNumber;
              trace(imageName);
  
              _root.createEmptyMovieClip(imageName, this.getNextHighestDepth());
  
              trace(imageNumber+": "+imageName + i);
  
              imageName.loadMovie(imageValue);
  
              imageName.width=500;
              imageName.height=500;
  
              _root.imageName.loadMovie(imageValue);
  
  
          } // for loop
      } // if success
      trace("________________");
      trace("1: "+image1);
      trace("2: "+image2);    
      trace("3: "+image3);
  }
  </code></pre>
  
  <p>If I trace the MCs in the Loop it works. The MCs are on the stage.
  BUT if I trace Clips outside the loop only the last MC are on the stage. All others are undefined. </p>