Skip to main content
CreativeFosse
Participant
December 9, 2011
Answered

Calculating the distance between two images..?

  • December 9, 2011
  • 3 replies
  • 869 views

Hi,

I'm trying to calculate the distance between two images (A and F - there are other images between A and F) but I can't seem to figure out how to do it the right way.

The image A.x is "(stage/2) - (A.width/2)" and image F.x is "E.x - imgSpace" which is a negative value (all the images x is of negative value to image A.x).

In my oppinion the calculation is F.x - A.x and although it might be right I still ned the value to be non-negative.

Does anyone know how to do this??

Thanks in advanse..

This topic has been closed for replies.
Correct answer sanjuAtWork

I think you can find distance with this equation,

var len:Numer = Math.abs(A.x - F.x);

3 replies

relaxatraja
Inspiring
December 9, 2011

trace(img2._x-(img1._x+img1._width));

Ned Murphy
Legend
December 9, 2011

If you mean the distance between their two x properties then the positrive version of that would be A.x - F.x since you say A.x s positive and F.x is negative.  But that is not necessarily the distance between the images if you mean the space that exists between them.

sanjuAtWorkCorrect answer
Participant
December 9, 2011

I think you can find distance with this equation,

var len:Numer = Math.abs(A.x - F.x);