# removeChild()?

**URL:** <https://forum.kirupa.com/t/removechild/302904>\
**Category:** Uncategorized\
**Created:** [January 9, 2010, 5:50pm UTC](https://forum.kirupa.com/t/removechild/302904 "2010-01-09T17:50:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathias5](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mathias5](https://forum.kirupa.com/u/mathias5)\
**Post date:** [January 9, 2010, 5:50pm UTC](https://forum.kirupa.com/t/removechild/302904/1 "2010-01-09T17:50:12Z")

</div>

Hi

I’ve got a problem with a menu… On the stage i have 4 movieclips. Each one is an element in the menu. For each movieclip i have a class which contains contents that should be displayed when a movieclip in the menu is clicked. So for so good.

But when i click on another movieclip the class for its contents beeing added over the old one and the old one want be removed. I really need to remove th current displayed class when a new movieclip is clicked.

Some one who can help me? :suppose\_maybe:

CODE

```auto

package
{
   import flash.display.MovieClip;
   import flash.events.MouseEvent;
   import flash.events.Event;
   
   public class Main extends MovieClip
   {
      public var portolio:MovieClip;
      public var about:MovieClip;
      public var clients:MovieClip;
      public var contact:MovieClip;
      
      private var _portfolio:Portfolio = new Portfolio();
      private var _about:About = new About();
      private var _clients:Clients = new Clients();
      private var _contact:Contact = new Contact();
	  
      private var _menuArr:Array;
      
      public function Main()
      {         
         _menuArr = [];
         _menuArr.push(portfolio,about,clients,contact);
         
         portfolio.theContent = _portfolio;
         about.theContent = _about;
         clients.theContent = _clients;
         contact.theContent = _contact;
         
         var menuLen:int = _menuArr.length;
         
         for (var i:int = 0; i < menuLen; i++)
         {
            _menuArr*.addEventListener(MouseEvent.CLICK, menuClicked);
			_menuArr*.buttonMode = true;
            _menuArr*.x = 0;
         }
      }
      
      private function menuClicked(event:Event):void
      {
         addChild(event.target.theContent);
      }
   }
}

```
