title: use of addChild inside a function to add a child into a previously added instance
body: <p>I wrote a simple function "adone" to add things to the stage and today I decided to make it add child to other objects as well but the test function "ad2" I made is not working right. what do you suggest?</p>
  
  <pre><code>package  {
  
  import flash.display.MovieClip;
  
  public class main extends MovieClip {
      public var ui:Array = new Array;
      public var splz:Array = new Array;
      public var pows:powsys = adone("powsz",powsys,ui,400,240);
      public var s1:powsyspsl = ad2("s1",powsyspsl,splz,100,100,"powsz");
  
      public function main() {
  
      }
      public function adone(nm,tp,lst,ex=0,ey=0) {
          nm = new tp();
          addChild(nm);
          lst.push(nm);
          nm.x = ex;
          nm.y = ey;
      }
      public function ad2(nm,tp,lst,ex=0,ey=0,par=null) {
          nm = new tp();
          par.addChild(nm);
          lst.push(nm);
          nm.x = ex;
          nm.y = ey;
      }
  }
  
  }
  </code></pre>