title: AS3: Referencing mc's from an array to then assign further array properties
body: <p>I have a number of 'items' (mc's) contained in a scrolling mc that can be drag-dropped to other matching mc's.
  The items names are listed in an array and I wish to assign variables of suitability and feedback to each mc from the array also. I think this is called an associative array?</p>
  
  <p>Having some trouble correctly referencing the items from the array.
  To explain, here's a working script with a simple array and an inefficient workaround:</p>
  
  <pre><code>var itemArray:Array = new Array("ball","box","hex");  //only a few items in this prototype
  scrollitems.ball.ifeedback = "Woo... hoo...";
  scrollitems.box.ifeedback = "Great!";
  scrollitems.hex.ifeedback = "Oops!";
  scrollitems.ball.isuitable = true;
  scrollitems.box.isuitable = true;
  scrollitems.hex.isuitable = false;
  
  for (var i:int=0; i&lt;itemArray.length; i++)
  {
     var itemname:String = String(itemArray[i]);
     var curritem:MovieClip = MovieClip(scrollitems.getChildByName(itemname));
     if (curritem != null)
     {
       curritem.startX = curritem.x;
       curritem.startY = curritem.y;
       curritem.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
       curritem.addEventListener(MouseEvent.MOUSE_UP, dropIt);
       curritem.buttonMode = true;
     }
  }
  </code></pre>
  
  <p>Here's a potentially better script using an associative array, but its not working as per CAP comments...</p>
  
  <pre><code>var itemArray:Array = new Array[{iname:"ball",isuitable:true,ifeedback:"Well done!"},
       {iname:"box",isuitable:true,ifeedback:"Great!"},
       {iname:"hex",isuitable:false,ifeedback:"Oops!"}];
  for (var i:int=0; i&lt;itemArray.length; i++)
  {
     var itemname:String = String(itemArray[i].iname); // THIS DOESNT WORK - ITEMNAME IS A STRING BUT CANT ASSIGN INAME TO THIS STRING??
     var curritem:MovieClip = MovieClip(scrollitems.getChildByName(itemname));
     if (curritem != null)
     {
       curritem.startX = curritem.x;
       curritem.startY = curritem.y;
       curritem.isuitable= curritem.isuitable;  //NOT WORKING - HOW TO ASSIGN THIS??
       curritem.ifeedback = curritem.ifeedback;  // NOT WORKING - HOW TO ASSIGN THIS??
       curritem.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
       curritem.addEventListener(MouseEvent.MOUSE_UP, dropIt);
       curritem.buttonMode = true;
     }
  }
  </code></pre>
  
  <p>Any suggestions for the AS3 newbie?</p>