# Removing the object itself by itself

**URL:** <https://forum.kirupa.com/t/removing-the-object-itself-by-itself/235626>\
**Category:** Uncategorized\
**Created:** [August 13, 2007, 3:23pm UTC](https://forum.kirupa.com/t/removing-the-object-itself-by-itself/235626 "2007-08-13T15:23:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xEnOn](https://avatars.discourse-cdn.com/v4/letter/x/85e7bf/32.png) [@xEnOn](https://forum.kirupa.com/u/xEnOn)\
**Post date:** [August 13, 2007, 3:23pm UTC](https://forum.kirupa.com/t/removing-the-object-itself-by-itself/235626/1 "2007-08-13T15:23:27Z")

</div>

i am trying to remove an object itself that is added to a movieclip on the stage.  
this is what i have at first:  
[AS]  
package {  
import flash.display.\*;

```
public class DocClass extends MovieClip {
	
	private var _mc:MovieClip;
	private var _otherSprite:MCfromLibrary;
	
	public function DocClass() {
		_mc = new MovieClip();
		_otherMC = new MCfromLibrary();
		_mc.addChild(_otherMC);
		addChild(_mc);
		_otherMC.removeMyself();
	}
}

```

}

package {  
import flash.display.\*;

```
public class MCfromLibrary extends MovieClip {
	
	public function MCfromLibrary() {
		//constructor
	}
	
	public function removeMyself() {
		parent.removeChild(this);
	}
}

```

}  
[/AS]

the MCfromLibrary is a class of a movieclip from the library.  
when i try to call the MCfromLibrary::removeMyself(), i got an error of:

```auto

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

```

how should i remove the object itself through itself?
