Delete onEnterFrame

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:

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: