OK, so I am now 90% there with this now, thanks to Alex and Jim.  I have
it working to auto-center if the panel re-sizes.  
 
Now the last part I still don't know how to tackle: the drawn graphics
can still extend over the edges of the Panel component if the graphics
are very large or there are a lot of them.  How do I get the Panel to
auto-trigger it's scrollbars and contain/mask the graphics being drawn?
I don't understand the Flex component framework enough to even know
where to begin.  Here is the complete code, and thank you for looking at
this:
 
 
<mx:Panel id="networkBrowserPanel" width="100%" height="100%"
layout="absolute" title="Network" >
       <c:NetworkLayout container="{networkBrowserPanel}" width="100%"
height="100%"
       outerAlpha="1" innerAlpha="1" outerColor="#ffffff"
innerColor="0x666666" circleRadius="200" /> 
</Panel>
 
-------------------
 
package components
{
 import mx.core.UIComponent;
 import flash.geom.Rectangle;
 
 public class NetworkLayout extends UIComponent
 {
  public var container:UIComponent;
  public var borderThickness:int;
  public var outerColor:uint;
  public var innerColor:uint;
  public var outerAlpha:int;
  public var innerAlpha:int;
  public var circleRadius:int;
  
  public function NetworkLayout()
  {
   super();
  }
  
        override protected function commitProperties():void
        {
   drawCircle();
        }
  
  override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void 
  {
   super.updateDisplayList(unscaledWidth, unscaledHeight); 
   measuredWidth = unscaledWidth;
   measuredHeight = unscaledHeight; 
   drawCircle();
  }
  
        override protected function measure():void
        {
         var rect:Rectangle = getBounds(container);
         measuredWidth = rect.width;
   measuredHeight = rect.height;
        }
        
        private function drawCircle():void
  {
   graphics.clear();
   var thisWidth:int = measuredWidth;
   var thisHeight:int = measuredHeight;
   var middleX:int = thisWidth/2;
   var middleY:int = thisHeight/2;
   graphics.lineStyle(borderThickness, outerColor, outerAlpha);
   graphics.beginFill(innerColor, innerAlpha)
   graphics.drawCircle(middleX, middleY, circleRadius); 
  }
      
 }
}

Jason Merrill 
Bank of America 
GT&O L&LD Solutions Design & Development 
eTools & Multimedia 

Bank of America Flash Platform Developer Community 


Reply via email to