//粘贴到帧上运行即可
var p1Start:Point = new Point(0,0);
var p1End:Point = new Point(50,50); var p2Start:Point = new Point(50,50);
var p2End:Point = new Point(100,100); var p:Point = new Point(); trace(checkPoint())
function checkPoint()
{
if (p1Start.x == p1End.x)
{
if (p2Start.x == p2End.x)
{
trace("平行线");
p = null;
}
else
{
p.x = p1Start.x;
p.y = p2Start.y+(p1Start.x-p2Start.x)/(p2End.x-p2Start.x)*(p2End.y-p2Start.y);
}
}
else if (p2Start.x == p2End.x)
{
p.x = p2Start.x;
p.y = p1Start.y+(p2Start.x-p1Start.x)/(p1End.x-p1Start.x)*(p1End.y-p1Start.y);
}
else
{
var K1:Number = (p1Start.y-p1End.y)/(p1Start.x-p1End.x);
var K2:Number = (p2Start.y-p2End.y)/(p2Start.x-p2End.x);
if (K1 == K2)
{
trace("平行线");
p = null;
}
else
{
var B1:Number = (p1Start.x*p1End.y-p1Start.y*p1End.x)/(p1Start.x-p1End.x);
var B2:Number = (p2Start.x*p2End.y-p2Start.y*p2End.x)/(p2Start.x-p2End.x);
p.x = (B2 - B1) / (K1 - K2);
p.y = K1 * p.x + B1;
}
}
return p;
}