# While mouse rollOver?

**URL:** <https://forum.kirupa.com/t/while-mouse-rollover/62385>\
**Category:** flash\
**Created:** [August 27, 2004, 11:01am UTC](https://forum.kirupa.com/t/while-mouse-rollover/62385 "2004-08-27T11:01:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![endy](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@endy](https://forum.kirupa.com/u/endy)\
**Post date:** [August 27, 2004, 11:01am UTC](https://forum.kirupa.com/t/while-mouse-rollover/62385/1 "2004-08-27T11:01:35Z")

</div>

while the mouse is over my button I want a function to be exicuted untill it is false. how can i do this?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 11:29am UTC](https://forum.kirupa.com/t/while-mouse-rollover/62385/2 "2004-08-27T11:29:57Z")

</div>

unfortunately, unlike director, flash has no on mousewithin event. So, in order to emulate that, you would need to combine onEnterFrame with onRollOver, onDragOver, onRollOut and onDragOut.

```auto
target.onRollOver = target.onDragOver = function(){
    this.onEnterFrame = function(){
        this.customMouseWithin();
    }
}
target.onRollOut = target.onDragOut = function(){
    delete this.onEnterFrame
}

```

be weary of this interfering with your own enterFrame though (if you have one for target already), you may need to set up a surrogate.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 27, 2004, 1:55pm UTC](https://forum.kirupa.com/t/while-mouse-rollover/62385/3 "2004-08-27T13:55:44Z")

</div>

I would go with senocular`s method too but you could also do this with hitTest()  
button instance name btn  
mc instance name mc1

checkhit = function () {  
if (!btn.hitTest(\_xmouse, \_ymouse)) {  
delete mc1.onEnterFrame;  
} else {  
mc1.onEnterFrame = moveup;  
}  
};  
function moveup() {  
this.\_y -= 1;  
}  
myInterval = setInterval(checkhit, 50);

you would have to clearInterval at some point.
