Griffith Designs

AS2 MovieClip Proximity to Mouse

by webmasterjunkie on Sep.26, 2010, under Actionscript, Programming

Here’s another neat little script that I had to piece together because there was no good resource available on the Internet. I have quite a few more helpful little scripts that I will post soon.

1
2
3
4
5
6
7
function get_proximity (clip:MovieClip):Number {
    var mouseyX:Number = _root._xmouse;
    var mouseyY:Number = _root._ymouse;
    var clipX:Number = clip._x;
    var clipY:Number = clip._y;
    return Math.sqrt ((mouseyX - clipX) * (mouseyX - clipX) + (mouseyY - clipY) * (mouseyY - clipY));
}
:, ,

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Connect