# Move towards (proximity)

**URL:** <https://forum.kirupa.com/t/move-towards-proximity/159729>\
**Category:** Uncategorized\
**Created:** [August 19, 2005, 4:22pm UTC](https://forum.kirupa.com/t/move-towards-proximity/159729 "2005-08-19T16:22:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mucho](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@mucho](https://forum.kirupa.com/u/mucho)\
**Post date:** [August 19, 2005, 4:22pm UTC](https://forum.kirupa.com/t/move-towards-proximity/159729/1 "2005-08-19T16:22:48Z")

</div>

Hi all,

what I would like to have is an mc (later a menu) that is sort of looking/striving/johnsin`towards the point as of a certain point when cross (e.g. half way of the stage). let`s say the menu is positioned at the top left corner and once the cursor crosses the border of towards the left the menu starts moving slowly towards the cursors (proximity). But not only that, the menu should stay in the upper left “area” and not come (e.g.) down all the way

I took Pom script as starting point… don`T know if this was the right approach.  
Help appreciated,

m.

```auto

startx=menu._x;
starty=menu._y;
MovieClip.prototype.move2=function(radius) {
	forceX=2*(Math.random()-.5)*radius;
	forceY=2*(Math.random()-.5)*radius;
	this._x=startx+forceX;
	this._y=starty+forceY;
}

this.onEnterFrame=function(){
	// Find distance
	var dx=_xmouse-menu._x;
	var dy=_ymouse-menu._y;
	var distance=dx*dx+dy*dy;
	menu.move2(10000/(distance+10));
}

```
