# Menu that bounces

**URL:** <https://forum.kirupa.com/t/menu-that-bounces/172238>\
**Category:** flash\
**Created:** [December 12, 2005, 6:20pm UTC](https://forum.kirupa.com/t/menu-that-bounces/172238 "2005-12-12T18:20:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xristoz](https://avatars.discourse-cdn.com/v4/letter/x/f05b48/32.png) [@xristoz](https://forum.kirupa.com/u/xristoz)\
**Post date:** [December 12, 2005, 6:20pm UTC](https://forum.kirupa.com/t/menu-that-bounces/172238/1 "2005-12-12T18:20:56Z")

</div>

I was trying to create something like this  
[http://www.webwasp.co.uk/tutorials/b04-menu-swing/index.php](http://www.webwasp.co.uk/tutorials/b04-menu-swing/index.php)  
Though even following the tutorial i find it difficult to succeed on making this menu to swing or even to appear in screen 😛  
I would really appreciate if you could help me on this !  
The difference that my menu will have is that in different areas when the mouse will be on them a different button will swing so no order to link them all and make them bounce as in the example …  
I just want when the mouse is over to an area lets say 20\<x\<240 and 135\<y\<175 the menu button to swing in from a fixed location lets say x=240 and from right to left and if the mouse is not over this area to swing back  
Same will happen to another area lets say 20\<x\<240 and 180\<y\<230 though with a different button to swing in…Same will happen to all the buttons my menu will have…when the mouse is over at the area to be brought there and if not all to go back

Thank you in advance

Ps. The code i used for trying to make only the first button (instance name given = test ) to swing…I made a button that was placed outside the screen of flash at 1350,135 while the size is 1280x1024 and wanted it to swing from right to left and enter the scrren at 240 when the mouse was on the area specified if not to swing back…and how will it be done if i had more buttons ?

// sets the x position for the menu to stop at and go back to  
goto = 240;  
backto = 1350;

// sets the speed - don’t set it too slow  
setInterval(mousePosition, 5);

// this function is called by the word ‘mousePosition’ in the setInterval above  
function mousePosition() {  
// sets the x position for the mouse to activate the menu movement  
if (\_xmouse\<=240)  
{  
if(\_xmouse\>=20)  
{  
if (\_ymouse\>=135)  
{  
if(\_ymouse\<=175)  
{  
test.\_x = test.\_x+bounce(“left”);

}}}}  
else {  
test.\_x = test.\_x-bounce(“right”);  
}  
}

// this function is called by ‘bounce’ in the mousePosition function above  
function bounce(leftOrRight) {  
// sets the swing properties  
if (leftOrRight == “right”) {  
go += (goto-test.\_x);  
go \*= .09;  
}  
if (leftOrRight == “left”) {  
go -= (backto-test.\_x);  
go \*= .09;  
}  
return go;  
}
