Reading Inactivity?


I’m working on a web menu, that has sub menus. I’m currently trying to get the sub menu to jump back to the main menu if the mouse is no longer inside the submenu zone.

It works if I move the mouse quickly to another part of the Flash area, but if I quickly move it out of the Flash area and onto say the html document, it doesn’t update fast enough, and thus still thinks the mouse is hovering over it.

I know I can simply update the movie frame rate which does work, but I was wondering if there is any way to get Flash to check to see if the mouse IS ACTUALLY ACTIVE over it, and if not close the submenu? This has me stumped.

onClipEvent(enterFrame) {
    if((_root._xmouse.hitTest(menu) == false) && (_root._ymouse.hitTest(menu) == false)) {

Sorry, but I can’t get your’s to work. Don’t know why. Must be doing something wrong. Anyway, I did the hittest theory, and here’s my code

onClipEvent (load) {
_visible = false;
count = 0;
onClipEvent (keyDown) {
if (this.hitTest(_root._xmouse, _root._ymouse, false) == false) {
count ++;
} else if (this.hitTest(_root._xmouse, _root._ymouse, false) && count > 0) {
count = 0;
if (count > 19) {
count = 0;
_root.gotoAndStop (“menu”);

The first hittest adds 1 to count if the mouse is outside of the zone. The second hittest resets count if the mouse re-enters the zone. And finally if count is 19 or more, it closes the sub menu.

As I said, it works perfectly, but if I quickly move the mouse out of the Flash zrea and somewhere else on the browser page it doesn’t always read it quick enough, and thus thinks it’s still there.

problem is that flash doesn’t record mouse movements outside of the flash movie. that means that if you move off the movie fast enough so that the last recorded mouse position was over the menu, flash will continue to think that’s where the mouse is. thus, doing hit tests doesn’t help you much.

one potential work around would be to check mouse positions for lack of movement. if the mouse hasn’t moved for 3 secs or so, chances are the mouse is out of the movie.

you only need run a check when the menus are up.

function initCheckMouse(){
   Mouse.oldx = _root._xmouse;
   Mouse.oldy = _root._ymouse;
   _root.mChecker = setInterval(checkMouse(), 3000);

function checkMouse(){
   if(Mouse.oldx != _root._xmouse && Mouse.oldy != _root._ymouse){
      // menu down code

that’s totally untested code, might need some syntax adjustment.

I had considered it, and now you’ve mentioned it, I’ll give it a go. Thanks.