title: AS3: How to add child in a container?
body: <p>I cannot sort this out few hours now ;(. I want to add a child in a container. This is what I have done so far. All the problems are in class Creator. This line par2.addChild(ship); //works, but this line par2.containerSDv.addChild(ship); //error:1119.</p>
  
  <p>Thanks</p>
  
  <pre><code>    public class Main extends MovieClip
  {
      private var containerSD:Container = new Container;
      private var ship:Ship2;
  
      public function Main()
      {
          // constructor code
          stage.addChild(containerSD);
          //ship = new Ship2;
          //containerSD.addChild(ship);
  
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>    public class AddChild2 extends SimpleButton
  {
      private var creatorche:Creator = new Creator;
      private var s:Ship2;
  
      public function AddChild2()
      {
          // constructor code
          addEventListener(MouseEvent.CLICK, onCLICK)
      }
  
      private function onCLICK(e:MouseEvent)
      {
          s = new Ship2;
          creatorche.onCreator(s, stage);
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>    public class Creator extends MovieClip
  {
      private var ship:MovieClip;
      private var containerSDv:Container = new Container;
  
      public function Creator()
      {
          // constructor code
      }
  
      public function onCreator(par1:MovieClip, par2:Stage)
      {
          ship = par1;
          //par2.addChild(ship); //works
          par2.containerSDv.addChild(ship); //error:1119
          ship.x = Math.random() * 200;
          ship.y = Math.random() * 200;
      }
  
  }
  </code></pre>
  
  <p>.</p>