Delete function onEnterframe - help?

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 :frowning:

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: