title: Refer to child of dynamically created movieclip actionscript 3
body: <p>So this is how I add a movieclip dynamically</p>
  
  <pre><code>var ClassReference:Class = getDefinitionByName('some_name') as Class;
  myBody = new ClassReference();
  myBody.name = "curtheme"; // I am giving it an instance name here
  addChild(myBody);
  </code></pre>
  
  <p>then I have many children of this dynamically added movie clip</p>
  
  <pre><code>var hair:Array = [curtheme.getChildByName('hair1'), curtheme.getChildByName('hair2'), curtheme.getChildByName('hair3'), curtheme.getChildByName('hair4'), curtheme.getChildByName('hair5'), curtheme.getChildByName('hair6'), curtheme.getChildByName('hair7'), curtheme.getChildByName('hair8')]; 
  
  var top:Array = [curtheme.getChildByName('top1'), curtheme.getChildByName('top2'), curtheme.getChildByName('top3'), curtheme.getChildByName('top4'), curtheme.getChildByName('top5'), curtheme.getChildByName('top6'), curtheme.getChildByName('top7'), curtheme.getChildByName('top8')];
  </code></pre>
  
  <p>this gives error: Access of undefined property curtheme. Obviously this is wrong but then how do I access its children by name? I hope my question is straight forward.</p>