What does your override of draw() look like and what are the drawX/Y and
width/height properties when it gets called?
override protected function draw( g:Graphics ):void
var start:Number = ( Math.PI / 2 );
var step:Number = Math.PI * 2 / _points;
var rad:Number = outerRadius;
var inRad:Number = innerRadius;
var angle:Number = start;
var stepAngle:Number = angle - step / 2;
var x:Number = rad * Math.cos( stepAngle ) + rad;
var y:Number = rad * Math.sin( stepAngle ) + rad;
g.moveTo( x,y );
x = inRad * Math.cos( angle ) + rad;
y = inRad * Math.sin( angle ) + rad;
g.lineTo( x, y );
for( var i:int = 1; i < points; i++ )
angle = start + ( i * step );
stepAngle = angle - step / 2;
g.lineTo( rad * Math.cos( stepAngle ) + rad,
rad * Math.sin( stepAngle ) + rad );
g.lineTo( inRad * Math.cos( angle ) + rad,
inRad * Math.sin( angle ) + rad );
Theres my draw override, i am not touching drawX, drawY, width, or height.
Is there a "best practices" document on extending the GraphicElement somewhere, because I think I am kinda missing the point. It would seem that in order to utilize the built in dynamic layout functionality that I cant bypass using height and width in my draw routine. ( or this drawX and drawY you mentioned )
So, I experimented making a new GraphicElement, just drawing a rectangle:
override protected function draw(g:Graphics):void
g.drawRect( drawX, drawY, width, height );
and all the layout functionality worked out ( i.e. it responded to right, left, width...etc ). So thank you for putting me on that track.
The question is, how would one draw radial based shapes using this same approach, and maintain functionality... i guess you would just have to modify your radius variables to be functions of width, height, drawX, and drawY.
Yeah, I think you find the center, do the math to determine the distance to
the edges of the bounding box and go from there.
Thanks for your help, working like a charm.