Thanks Glen - this sounds like another good solution. I assume this would
work when the polygon is just a single line?

-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike
Sent: 16 June 2011 14:48
To: Flash Coders List
Subject: Re: [Flashcoders] Detecting if line crosses movie clip

Hi,

     Can you measure the vector distance between the centre of the 
polygon and the centre of the ball? If that is 0,0, and the diameter of 
the circle is less than the smallest of width / height of the box, then 
you are inside.

     Glen

On 16/06/2011 13:58, Paul Steven wrote:
> Working on a game where the player must draw around some colored balls on
> screen by dragging the mouse to create the polygon that surrounds the
> objects.
>
> The polygon is created by drawing a series of lines every time the mouse
> moves. If one of these lines intersects one of the balls (movie clip) I
need
> to perform an action.
>
> So my question is how to detect when the line intersects a movie clip?
>
> The following is unsuitable as it treats the line as a rectangle e.g a
> vertical line will have a lot of hit area that I do not want to be hit
area
>
> if (ballMC.hitTestObject(lineMC)) {
>
> My other best suggestion is to use the 4 lines that make up the bounding
box
> of the ball movie clip and do a line intersection test for each line
against
> the line being drawn. This seems overly complex so before I try this I
> wanted to check there is not a simpler solution.
>
> Thanks in advance
>
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
ca
_______________________________________________
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