# Using a deconstructor

**URL:** <https://forum.kirupa.com/t/using-a-deconstructor/219615>\
**Category:** flash\
**Created:** [March 18, 2007, 6:40pm UTC](https://forum.kirupa.com/t/using-a-deconstructor/219615 "2007-03-18T18:40:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arunforce](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@arunforce](https://forum.kirupa.com/u/arunforce)\
**Post date:** [March 18, 2007, 6:40pm UTC](https://forum.kirupa.com/t/using-a-deconstructor/219615/1 "2007-03-18T18:40:07Z")

</div>

Hi! First post. 🙂

Well, I know that in C++ you can use a deconstructor, but I tried googling around for one, but couldn’t find anything.

The reason I need it is, lets say I have a class.

```auto

class baby
{
      function baby(name)
      {
           attachMovie(blablblalb, name, blalala);
      }
}

```

Ok, then I make an object out of the class:

```auto

baby1 = new baby("kirupa");

```

Now Kirupa engages in a battle, and dies. ☹  
So, I deleted Kirupa:

```auto

delete baby1;

```

The problem here is that when I deleted him, logically, the movieclip I attached to the scene gets removed. That’s why I need a deconstructor, so when the object is deleted, the movieclip should be removed. I rather not use a workaround, unless their is no other option. ☹

Please tell me there is a deconstructor! :thumb2:
