title: load library objects by string list, AS3
body: <p><strong>How do I load library objects by string list using Flash and AS3?</strong><br> I need to understand string lists, arrays, and sprites better. </p>
  
  <p><strong>WHAT I WANT TO DO</strong><br>
  Load enemies to stage using a string list "Orange ball, red ball, green ball etc"</p>
  
  <p><strong>EXPLANATION</strong><br>
  The tutorials I've been given are too basic, or they are incomplete
  examples that don't explain the classes being used. </p>
  
  <p>Trace statements are not showing me how I'm accessing the name or class of an object.
  I need examples. Non-packaged classes preferred. Thanks. </p>
  
  <p><strong>WHAT I GOT WORKING</strong> "I knew I'd mix up the class and name"<br>
  SYMBOL PROPERTIES<br>
  name is <em>they're not name specific, I call mine noname"</em><br>
  class is <em>Pyramid</em><br></p>
  
  <pre><code>//Creates 10 enemies and trace statement
  import flash.display.Sprite;
  var sprites:Array = new Array();
  for(var i:Number=0;i&lt;10;i++){
      //var test:Sprite = new Sprite();
      var test:Pyramid = new Pyramid();
          sprites.push(test);
      addChild(test);
      test.name = "littlebox_"+ i
      trace(test.name)
      with(test){
  
          x=i*25;
  
         }
  }
  
  /////////////////////////////////////////////////////////////////////// 
  
  /*debu's example*/
  //Creates 10 enemies 
  var enemyArray:Array = new Array(); 
  
  for (var i:int = 0; i &lt; 10; i++) 
  { 
     var noname:Pyramid = new Pyramid(); 
     noname.x = i*10; //this will just assign some different x and y value depending on i. 
     noname.y = i*11; 
     enemyArray.push(noname); //put the enemy into the array 
     addChild(noname); //puts it on the stage 
  }
  
  ///////////////////////////////////////////////////////////////////////
  
  //centered and trace statement
  var sprite:Sprite;
  var noname:Pyramid = new Pyramid; 
  //var noname:Pyramid2 = new Pyramid2; 
  sprite = new Sprite();
  sprite.name = "Pyramid" + 1;
  addChild( noname);
  noname.x = stage.stageWidth/3;
  noname.y = stage.stageHeight/3;
  trace( getChildByName( "Pyramid" + 1 ) ); // [object Sprite]
  </code></pre>
  
  <p><a href="http://www.ashcraftband.com/myspace/videodnd/so___.jpg" rel="nofollow noreferrer">alt text http://www.ashcraftband.com/myspace/videodnd/so___.jpg</a></p>
  
  <p><strong>PREVIOUS MODIFIED</strong><br></p>
  
  <pre><code>var enemyList:Object = new Object();
          //var enemy:Sprite = new Sprite();
  var enemy:BadGuy = new BadGuy();
  enemy.name = "BadGuy";
  enemyList [enemy.name] = enemy;
  
  //var enemyList:Object = new Object();  
  //for (var i:int = 0; i &lt; 10; i++) {
          //var enemy:Sprite = new Sprite(); 
  //var enemy:BadGuy = new BadGuy(); 
  //enemy.name = "BadGuy" + i;  
  //enemyList [enemy.name] = enemy;  
  //}  
  
  //for (var i:String in enemyList){  
  //var enemy:Sprite = enemyList[i]  
  //do something to enemy sprite  
  //}
  </code></pre>
  
  <h1>PLEASE POST MORE ARRAY STUFF</h1>