[Extendflash] Calculate polygon area

julifos julifos at pescadosweb.com
Thu Mar 16 11:37:40 GMT 2006


Hi all!

I'm trying to calculate the area of a random polygon, and trying first to
get the list of vertices onto an ordered array. But seems that, when you
access the "vertices" of the shape, they are given in a un-ordered fashion.

For example, if I have a given shape with six vertices a, b, c, d, e, f, and
I use this:

sh = fl.getDocumentDOM().selection[0];
for(i=0;i<sh.vertices.length;i++){
    fl.trace([sh.vertices[i].x, sh.vertices[i].y]);
}

It will trace the vertices in apparently random order.

Am I doing something wrong? (or can I do something to order the vertices, as
if I was to re-draw the shape?)


jj




More information about the Extendflash mailing list