PDA

View Full Version : proximity



ivanwright
July 24th, 2003, 04:11 PM
does anyone know how to get something to happen according to the mouse's proximity to an object? like say i have a square & i want that square to get bigger the closer the mouse gets to it... how would one do that?

senocular
July 24th, 2003, 04:43 PM
heres a mouse distance formula. Just use that to get a distance and base your reaction on that distance (like scale = distance);


Mouse.distanceFrom = function(obj){
var dx = obj._x - obj._parent._xmouse;
var dy = obj._y - obj._parent._ymouse;
return Math.sqrt(dx*dx+dy*dy);
};
// use: distance = Mouse.distanceFrom(myMovieClip);