# Garbage Cleanup - onEnterFrame, Intervals,?

**URL:** https://forum.kirupa.com/t/garbage-cleanup-onenterframe-intervals/226762
**Category:** Uncategorized
**Created:** [May 23, 2007, 8:19pm UTC](https://forum.kirupa.com/t/garbage-cleanup-onenterframe-intervals/226762 "2007-05-23T20:19:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nickcherryjiggz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nickcherryjiggz/32/2107_2.png) [@nickcherryjiggz](https://forum.kirupa.com/u/nickcherryjiggz)
#### Post date: [May 23, 2007, 8:19pm UTC](https://forum.kirupa.com/t/garbage-cleanup-onenterframe-intervals/226762/1 "2007-05-23T20:19:44Z")

</div>

A project I’m working on is working just fine at first, but as I perform more actions, it slows down noticeably. I’ve made sure to clear any onEnterFrame and setInterval events, so I don’t think the problem lies there. Most likely, it’s because practically every time an action occurs, much of the content on the screen is redrawn/recreated. However, every time I create a movie clip, text field, shapes, etc., I call a function to remove it beforehand:

```auto
function killThis(mc:MovieClip, thingsName:String):Void{
    var obj:Object = mc[thingsName];
    if (obj instanceof MovieClip){
        obj.removeMovieClip();
    }
    else if (obj instanceof TextField){
        obj.removeTextField();
    }
}

killThis(_root, "calendarContainer");
_root.createEmptyMovieClip("calendarContainer", _root.getNextHighestDepth());

```

Any suggestions as to what I may be doing wrong?
