Look into MovieClip.getBounds() and MovieClip.getRect(). For example,
you could use:
import flash.geom.Point;
// ...
function getCenter(shape:MovieClip):Point {
var bounds:Object = shape.getBounds(this);
var center:Point = new Point();
center.x = (bounds.xMax - bounds.xMin) / 2;
center.y = (bounds.yMax - bounds.yMin) / 2;
return center;
}
(Assuming that the scope of this function is a movie clip timeline or a
subclass of MovieClip.)
―
Mike Keesey
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of matt stuehler
> Sent: Thursday, September 21, 2006 9:58 AM
> To: Flashcoders mailing list
> Subject: [Flashcoders] Algorithm to find "center" of an irregular
shape
>
> All,
>
> I'm not too handy with geometry, so I'm not even sure this is
> possible, but I'm looking for an algorithm that will determine the
> "center" of an irregular shape.
>
> I'm not even sure there is a meaningful definition of a "center", but
> I'd like to at least find a point that is within the area of the
> shape. (I realize that with certain shapes, like a donut, this might
> be an intractible problem), so even some rough approximation would
> help.
>
> In this particular application, the shapes are the areas between the
> lines created when graphing several time series on a chart (e.g., the
> price of several stocks, graphed over time)
>
> Many thanks in advance for any advice or insights!
>
> Cheers,
> Matt Stuehler
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com