title: Actionscript 3 how to delete instance from stage
body: <p>So I have two movieclips, sRP_mc and dP_mc, on the first frame. Now, when either of the movieclips are clicked on, then I want the movieclip to be removed from the stage and then I want the frame to change (I want the movie to go to frame 5). On frame 5, there is a close button, which, if clicked, takes you back to frame 1 (but when it takes you back to frame 1, I want the movieclip which was clicked on to not be there anymore). Here is my code for my first frame (frame 1).</p>
  
  <pre><code>import flash.events.MouseEvent;
  stop();
  if (sRP_mc.visible == true) {
      sRP_mc.addEventListener(MouseEvent.CLICK, sRPClicked);
      function sRPClicked(event:MouseEvent):void {
          sRP_mc.removeEventListener(MouseEvent.CLICK, sRPClicked);
          removeChild(sRP_mc);
          gotoAndPlay(5);
      }
  }
  
  if (dP_mc.visible == true) {
      dP_mc.addEventListener(MouseEvent.CLICK, dPClicked);
      function dPClicked(event:MouseEvent):void {
          dP_mc.removeEventListener(MouseEvent.CLICK, dPClicked);
          removeChild(dP_mc);
          gotoAndPlay(10);
      }
  }
  </code></pre>
  
  <p>and on frame 5, there is a close button and the code is this.</p>
  
  <pre><code>import flash.events.MouseEvent;
  stop();
  close_btn.addEventListener(MouseEvent.CLICK, closeScreen);
  function closeScreen(event:MouseEvent):void {
      gotoAndStop(1);
  }
  </code></pre>
  
  <p>and on frame 10 there is also a close button the code is this.</p>
  
  <pre><code>import flash.events.MouseEvent;
  stop();
  close_btn.addEventListener(MouseEvent.CLICK, closeScreen2);
  function closeScreen2(event:MouseEvent):void {
      gotoAndStop(1);
  }
  </code></pre>
  
  <p>As you can see, if sRP_mc or dP_mc are removed using the removeChild method, then sRP_mc and dP_mc should not be visible (.visible != true) but when I play this, it says that sRP_mc and dP_mc are always visible and the child does not get removed completely from the stage (or I think the isntance keeps coming back whenever I go back to frame 1). Why is it doing this and how would I fix it?</p>