MFarooqui <[EMAIL PROTECTED]> wrote: > I would like to be able to click a number of points on the stage and have > the area calculated .
Hi Mushtaq, You could divide the area up into triangles, then calculate the area of each triangle. on getArea(point1, point2, point3) hMin = min(point1.locH, point2.locH, point3.locH) hMax = max(point1.locH, point2.locH, point3.locH) vMin = min(point1.locV, point2.locV, point3.locV) vMax = max(point1.locV, point2.locV, point3.locV) return (hMax - hMin) * (vMax - vMin) / 2 end getArea The difficulty will be to create a list of triangles which all fit together to fill the area. If the shape is convex, you can create n-2 triangles using the points 1, m-1 and m, where m varies from 3 to n. Here's the beginning of an answer. The order in which the points are defined is critical, so you will need to do some serious tweaking in order to get consistent and accurate results: on getConvexArea(aListOfPoints) -- WARNING: INCOMPLETE FIRST DRAFT - RESULTS ARE LIKELY TO BE INACCURATE i = aListOfPoints.count - 2 if i < 1 then return 0 end if point1 = aListOfPoints.getLast() point2 = aListOfPoints[i + 1] tArea = 0 repeat while i point3 = aListOfPoints[i] tArea = tArea + getArea(point1, point2, point3) point2 = point3 i = i - 1 end repeat return tArea end getConvexArea -- Example in the Message window: Cheers, James [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]