# Delete function onEnterframe - help?

**URL:** <https://forum.kirupa.com/t/delete-function-onenterframe-help/131133>\
**Category:** Uncategorized\
**Created:** [December 12, 2004, 3:17pm UTC](https://forum.kirupa.com/t/delete-function-onenterframe-help/131133 "2004-12-12T15:17:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)\
**Post date:** [December 12, 2004, 3:17pm UTC](https://forum.kirupa.com/t/delete-function-onenterframe-help/131133/1 "2004-12-12T15:17:06Z")

</div>

Hi,

I have a function which starts on one frame, but I’d like it to stop on the following frame - how do I do that??

I’ve tried doing it by setting a variable and using an ‘if’ statement to stop it once the variable has changed…but it’s not working ☹

I’m not very good with if’s and else if’s - can anyone help?? I have a bar which remains on stage at all times and pages are loaded into level1. On one of my pages, the bar sticks to \_ymouse, but I need it to stop doing that when I exit the page. Can anyone help?? Here’s what I’ve got so far…don’t laugh - it kinda works… :puzzled:

\_level0.barMC.onEnterFrame = function() {

this.onMouseMove = function () {  
var yMouse = \_root.\_ymouse;

if(stick = false){  
delete this.onEnterFrame;  
}  
if(Math.abs(yMouse - this.\_y) \< 1) {  
this.\_y = yMouse;  
} else {  
this.\_y -= (this.\_y-yMouse) / 6;  
}  
if(\_level0.barMC.\_y\<59){  
\_level0.barMC.\_y = 59;  
}  
}  
};

Many thanks in advance!!! :thumb:
