# Moving 3d menu following mouse needs limits + clickable buttons behind a movieclip

**URL:** <https://forum.kirupa.com/t/moving-3d-menu-following-mouse-needs-limits-clickable-buttons-behind-a-movieclip/293401>\
**Category:** flash\
**Created:** [July 28, 2009, 2:37pm UTC](https://forum.kirupa.com/t/moving-3d-menu-following-mouse-needs-limits-clickable-buttons-behind-a-movieclip/293401 "2009-07-28T14:37:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thevibe](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@thevibe](https://forum.kirupa.com/u/thevibe)\
**Post date:** [July 28, 2009, 2:37pm UTC](https://forum.kirupa.com/t/moving-3d-menu-following-mouse-needs-limits-clickable-buttons-behind-a-movieclip/293401/1 "2009-07-28T14:37:10Z")

</div>

Hi guys,

Here’re my 2 problems:

1-I did a menu moving in 3d following my mouse movement but with boundaries to keep the front in face of the user. It’s working well but when it reaches the boundaries on X or Y, the stop is quite too hard. I was thinking it should be great if the menu was always moving… following the mouse within the boundaries or following a new path if the mouse is out. COuld i put a script after the “else” to make the rotation go on, within my boundaries, but without the mouse movement since the mouse will be in a corner or something like that ?

Here’s the script now:

addEventListener(Event.ENTER\_FRAME, loop);

function loop(e:Event):void  
{  
var xDist:Number = mouseX - stage.stageWidth \* 0.5  
var yDist:Number = mouseY - stage.stageHeight \* 0.5

if((karate.rotationY - (xDist \* 0.001) \>-10)&&(karate.rotationY - (xDist \* 0.001) \<10))

karate.rotationY -= xDist \* 0.001;

else

karate.rotationY -= xDist \* 0.000;

if((karate.rotationX - (yDist \* -0.001) \>-5)&&(karate.rotationX - (yDist \* -0.001) \<5))

karate.rotationX -= yDist \* -0.001;

else

karate.rotationY -= yDist \* 0.000;  
}

2-My second question is about my menu buttons. I want them to be on lower layer cause it help creating my 3d scene cause sometimes it is a part cover by my image on the top. But the buttons stop to be clickable when they are behind something (even a part behind). I want them to be clickable at all time. The strange thing is i checked out in the forum and a lot of people have the opposite problem… their buttons still work. How can i make mine clickable ?

I would really appreciate your help guys  
Thanks  
Thevibe
