# removeChild from inside a class

**URL:** <https://forum.kirupa.com/t/removechild-from-inside-a-class/321862>\
**Category:** flash\
**Created:** [May 3, 2011, 4:23pm UTC](https://forum.kirupa.com/t/removechild-from-inside-a-class/321862 "2011-05-03T16:23:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![molkman](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@molkman](https://forum.kirupa.com/u/molkman)\
**Post date:** [May 3, 2011, 4:23pm UTC](https://forum.kirupa.com/t/removechild-from-inside-a-class/321862/1 "2011-05-03T16:23:00Z")

</div>

Hello,  
I have a hopefully very simple problem.

I created two children from my document class “MainClass”. One (hero) is of the class “HeroDo” and another is from the class “canDy”.

```auto
public static var hero:HeroDo=new HeroDo
public static var blue:canDy=new canDy

public function MainClass () {
            this.addChild(blue)
            this.addChild(hero)
...

```

Now the simple thing I want to do is to remove the “blue” child from within a function of the “hero” child and the hero child to remove itself from “its inside”.

I tried this, but it gives me an error. :C

```auto
removeChild(MainClass.blue)

```

I’m very new to AS3, so sorry if that is a stupidly easy question.

Thanks in advance.
