# Scale based on mouse proximity

**URL:** <https://forum.kirupa.com/t/scale-based-on-mouse-proximity/215481>\
**Category:** Uncategorized\
**Created:** [February 7, 2007, 4:57pm UTC](https://forum.kirupa.com/t/scale-based-on-mouse-proximity/215481 "2007-02-07T16:57:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaplanyo](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@kaplanyo](https://forum.kirupa.com/u/kaplanyo)\
**Post date:** [February 7, 2007, 4:57pm UTC](https://forum.kirupa.com/t/scale-based-on-mouse-proximity/215481/1 "2007-02-07T16:57:25Z")

</div>

I would like to scale a movie clip based on how close the mouse gets to it, but flash slows when there are a ton of these. I’m looking for a new method – any ideas?

onMouseMove = function(){  
var dx:Number = this.\_x - \_parent.\_xmouse;  
var dy:Number = this.\_y - \_parent.\_ymouse;  
var dist:Number = Math.round(Math.sqrt(dx_dx + dy_dy));  
if (dist\<100){  
this.\_xscale = this.\_yscale = 200 - dist;  
this.\_alpha += 2;  
} else if (dist\>100){  
this.\_xscale = this.\_yscale = 100;  
this.\_alpha = 20;  
}  
}
