# How to detect if a circle is crossing a diagonal line?

**URL:** <https://forum.kirupa.com/t/how-to-detect-if-a-circle-is-crossing-a-diagonal-line/307592>\
**Category:** flash\
**Created:** [April 6, 2010, 2:16pm UTC](https://forum.kirupa.com/t/how-to-detect-if-a-circle-is-crossing-a-diagonal-line/307592 "2010-04-06T14:16:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zomis](https://avatars.discourse-cdn.com/v4/letter/z/e56c9b/32.png) [@Zomis](https://forum.kirupa.com/u/Zomis)\
**Post date:** [April 6, 2010, 2:16pm UTC](https://forum.kirupa.com/t/how-to-detect-if-a-circle-is-crossing-a-diagonal-line/307592/1 "2010-04-06T14:16:48Z")

</div>

Currently, I am using the code below. But it is telling me that the circle is starting to hit the line when it’s y position is 40. But since the circle actually isn’t crossing the line itself (virtually) until it’s y position is at about 205, I don’t want the trace-action called so early.

I know that there exists a “hitArea” property of all DisplayObjects (Sprites included), but I don’t know if - or how - I could use it to fix this situation.

```auto
var circle: Sprite = new Sprite();
circle.graphics.beginFill(0xFF0000);
circle.graphics.drawCircle(0, 0, 10);
circle.x = 170;
circle.y = 30;
addChild(circle);

var line: Sprite = new Sprite();
line.graphics.lineStyle(1, 0xFF0000);
line.graphics.lineTo(200, 200);
line.y = 50;
addChild(line);

addEventListener(Event.ENTER_FRAME, fncTestHit);
function fncTestHit(event: Event) {
    circle.y += 1;
    if (circle.hitTestObject(line)) trace('hits line at '+circle.y);
    if (line.hitTestObject(circle)) trace('hits unit at '+circle.y);
}

```
