Calculating area of a shape (no curves involved)
Hi all. I have some code that provides four draggable points with lines connecting them, as if you're dragging the corners of a room:
Code:
_root.createEmptyMovieClip("line_mc1", 1);
MovieClip.prototype.drawLine = function()
{
this.clear();
this.lineStyle(1,0x0000FF,100);
this.moveTo(mc1._x+mc1._width/2, mc1._y+mc1._height/2);
this.lineTo(mc2._x+mc2._width/2, mc2._y+mc2._height/2);
this.lineTo(mc3._x+mc3._width/2, mc3._y+mc3._height/2);
this.lineTo(mc4._x+mc4._width/2, mc4._y+mc4._height/2);
this.lineTo(mc1._x+mc1._width/2, mc1._y+mc1._height/2);
}
mc1.swapDepths(2);
mc2.swapDepths(3);
mc3.swapDepths(4);
mc4.swapDepths(5);
line_mc1.drawLine();
mc1.onPress = mc2.onPress = mc3.onPress = mc4.onPress = function()
{
this.startDrag();
line_mc1.onEnterFrame = drawLine;
}
mc1.onRelease = mc2.onRelease = mc3.onRelease = mc4.onRelease = function()
{
delete line_mc1.onEnterFrame;
this.stopDrag();
}
I am looking for a way to calculate the area of the shape that is made. I haven't had much success in finding how to calculate the area of irregular shapes, although I did find this which gives the general idea. It's just a little over my head: http://www.pharmacy.ferris.edu/facul...oordinates.pdf
Any help pointing me in the right direction would be greatly appreciated, thanks!