# Delete onEnterFrame

**URL:** <https://forum.kirupa.com/t/delete-onenterframe/281234>\
**Category:** Uncategorized\
**Created:** [February 6, 2009, 11:17am UTC](https://forum.kirupa.com/t/delete-onenterframe/281234 "2009-02-06T11:17:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [February 6, 2009, 11:17am UTC](https://forum.kirupa.com/t/delete-onenterframe/281234/1 "2009-02-06T11:17:53Z")

</div>

Hello, recently I have been firing a few onEnterFrame functions depending on the users interaction. ie. animations/loading bars etc. Now I have been trying to streamline my code practice, so it’s nice and efficient, and most importantly - I get to delete those onEnterFrame functions when they are complete!!

The way I call my functions doesn’t neccessarily delete my onEnterFrames when they have completed their task. Sometimes it does, sometimes it don’t.

here’s how I do it:

```auto
function nterFrame()
{
    obj_mc._x += 5;
    if (obj_mc._x > Stage.width)
    {
        delete this.onEnterFrame;
    }
}

start_mc.onRelease = function()
{
    obj_mc.onEnterFrame = nterFrame;
}

```

Is there a more efficient way to get this dialogue to work? As if I start using this method to call a progress bar % and it is concerned with ‘loading’ something, then this onEnterFrame doesn’t seem to work properly. For simple animations, it’s ok.  
Any hints???  
:genius:
