# Display Object problems

**URL:** <https://forum.kirupa.com/t/display-object-problems/270447>\
**Category:** Uncategorized\
**Created:** [September 10, 2008, 3:03am UTC](https://forum.kirupa.com/t/display-object-problems/270447 "2008-09-10T03:03:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thefunkster](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@thefunkster](https://forum.kirupa.com/u/thefunkster)\
**Post date:** [September 10, 2008, 3:03am UTC](https://forum.kirupa.com/t/display-object-problems/270447/1 "2008-09-10T03:03:12Z")

</div>

Hi - I’ve done a bunch of searching and googling on this, but I can’t figure it out. I want to remove the clip on the the stage when the new one is added. mySprite was the holder. It works the first time, but after that … I get the

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.  
at flash.display::DisplayObjectContainer/removeChild()  
at MethodInfo-1() error –

and I can’t track it down.

```auto
 
// these are buttons // 
CanopyAds.addEventListener(MouseEvent.CLICK, CanopyListener); 
GovCircle.addEventListener(MouseEvent.CLICK, GovListener)
        
       
        function CanopyListener(event:MouseEvent):void { 
            
            if(welcomeMC) { 
                removeChild(welcomeMC) } 
            if(mySprite) { 
                removeChild(mySprite); } 
            
            var canopyPI = new PortfolioItem(); 
        
            canopyPI.setText("This is some text.")
            addChild(canopyPI); 
            
            addChild(mySprite);
            mySprite.addChild(canopyPI); 

            
            } 
            
        
        function GovListener(event:MouseEvent):void { 
            
            if(welcomeMC) { 
                removeChild(welcomeMC) } 
            
            if(mySprite) { 
                removeChild(mySprite); } 
            
            var gcPI = new PortfolioItem(); 
            gcPI.setText("This is some different text")
            
            addChild(mySprite);
            mySprite.addChild(gcPI); 

            } 

```

eventually i’ll put this into a function/class so i’m not repeating the code, but right now I’m just trying to get it to work right.

thanks in advance!
