# Calculate the distance between 2 objects! But with heigth and width for calculating!

**URL:** <https://forum.kirupa.com/t/calculate-the-distance-between-2-objects-but-with-heigth-and-width-for-calculating/252474>\
**Category:** flash\
**Created:** [February 20, 2008, 2:17pm UTC](https://forum.kirupa.com/t/calculate-the-distance-between-2-objects-but-with-heigth-and-width-for-calculating/252474 "2008-02-20T14:17:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![D\_I\_C\_E](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@D\_I\_C\_E](https://forum.kirupa.com/u/D_I_C_E)\
**Post date:** [February 20, 2008, 2:17pm UTC](https://forum.kirupa.com/t/calculate-the-distance-between-2-objects-but-with-heigth-and-width-for-calculating/252474/1 "2008-02-20T14:17:46Z")

</div>

[FONT=Tahoma]Hey dudes!

Humm, i need some help with one thing, i have many objects in the stage, and i use the mouse to calculate the distance between a random target in this stage, using the x and y position of mouse, i can do this perfectly getting the x and y position of target object.

A use that to give me in % the distance of target object, and starting animations, between the percentage.

Today i use the Pythagorean theorem. to do that.

```php
c = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));

```

But, now i need that be influenced by the width and height of object, as they \_x,\_y, stay allong the object, a do a little drain to better explanation:

![](http://img185.imageshack.us/img185/6942/pytagorasii6.gif)

Someone can help me? With this? What i have to do, to getting the 0% all over the object.

Thanks, for the help!!  
[/FONT]
