title: As3 hit test with programmatically added movieclips (without instance names)
body: <p>I have a main class where I have the functionality to add a wall to the stage. </p>
  
  <p>Previously, I declared this as</p>
  
  <pre><code>public var wall_cubular_1:Wall_cubular_1 = new Wall_cubular_1();
  </code></pre>
  
  <p>and then added it like this</p>
  
  <pre><code>addChild(wall_cubular_1);
  </code></pre>
  
  <p>And then in the character class (which are supposed to hittest the walls) I had the following</p>
  
  <pre><code>wallHit = this.hitTestObject(_root.wall_cubular_1)
  </code></pre>
  
  <p>However, this meant I could only place one wall at a time from the main class, since every time I added a new one, the old one just vanished and the new one was placed. As if I replaced it.</p>
  
  <p>So I changed the main class, removing the public var of the wall, and instead had it setup like this</p>
  
  <pre><code>var wall_cubular_1:Wall_cubular_1 = new Wall_cubular_1();
  addChild(wall_cubular_1);
  </code></pre>
  
  <p>in the function which adds the walls.</p>
  
  <p>Now the characters can't hit test the walls as it isn't public. So I tried changing the hittest to this</p>
  
  <pre><code>wallHit = this.hitTestObject(stage.wall_cubular_1)
  </code></pre>
  
  <p>But it doesn't work!</p>
  
  <p>I'm totally lost. How do I fix this?</p>
  
  <p>Thanks</p>