Let's call the position of the mouse click on the stage (clickedX, clickedY)
The starting coordinates are (startX, startY)
The ending coordinates are (endX , endY)

The general equation of your line, for any variables X and Y, is:
Y == (X - startX) * (endY - startY) / (endX - startX)

So when the user clicks on the stage, the values of clickedX and clickedY
would need to satisfy the following equation:
clickedY == (clickedX - startX) * (endY - startY) / (endX - startX)

If this is true for clickedX and clickedY then that means the click fell on
the line.  Of course you would probably have to provide a bit of an error
margin because you can't accurately evaluate the equality (==) of real
numbers.

A



On Sat, Aug 30, 2008 at 9:18 PM, Weyert de Boer <[EMAIL PROTECTED]> wrote:

> May I ask a related question? How can I detected if a user has clicked on a
> line (or later a bezier path) ? I am having the starting and ending
> coordinates of this line and so also the distance.
> Now I am would like to check if the user has clicked within this line
> with/or without a specific radius. I am currently a bit clueless how to
> solve this problem.
>
> I know it's close what you have given earlier.
>
> Yours,
> Weyert
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to