title: ActionScript 3 Access Dynamically Added MovieClips that are With-In Other MovieClips
body: <p>How would I access a MovieClip that I had dynamically added to a parent MovieClip.</p>
  
  <p>So say for example I have a movieclip (mc_a), and within it I created a var like so:</p>
  
  <pre><code>var b:DisplayObject = new mc_b();
  </code></pre>
  
  <p>I had manually added mc_a to my stage and gave it the "Instance Name": a.</p>
  
  <p>So my question is how do I access b (which is an instance of mc_b) when it is within a (which, in turn, is an instance of mc_a)?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I have the following variable referencing a MovieClip located on frame 1 of another MovieClip named "mc_dock":</p>
  
  <pre><code>var btn_pause:DisplayObject = new mc_pause();
  </code></pre>
  
  <p>I access the dock on the main timeline under frame 1 using the following line:</p>
  
  <pre><code>var dock:mc_dock = new mc_dock();
  </code></pre>
  
  <p>and then I used the following 2 lines to see if I can access btn_pause from the main timeline (both of which don't work [by that I mean they return "null"]):</p>
  
  <pre><code>trace(dock.btn_pause);
  trace(dock.getChildByName("btn_pause");
  </code></pre>
  
  <p>When running I get a null value for both trace statements and the following error:</p>
  
  <blockquote>
    <blockquote>
      <p>TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at mc_dock/frame1()</p>
    </blockquote>
  </blockquote>