Let's say you dynamically draw 50 lines on the stage.

I'd like to know how to check which of these lines is the nearest to a certain point (e.g. the mousepointer). And ofcourse I'd like to know the fastest way.

I'm starting to understand it, but I need a little help to really get it.

What I understand is that the point on a linesegment closest to a certain point is the intersectionpoint of the perpendicular line between the "certain point" and the line.

But I can't think of an easy way to calculate this.

Anyone?

Thanks in advance!