minWidth and minHeight seem to work for me :

<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" 
        minWidth="400" minHeight="400" 
       /> 
        </mx:Panel>

OR, if you need to calculate it on measure() or somewhere else in your code 
then:

override protected function measure():void
{
        var rect:Rectangle = getBounds(container);
        measuredWidth = rect.width;
        measuredHeight = rect.height;
        measuredMinWidth=circleRadius*2;
        measuredMinHeight=circleRadius*2;               
}

for example ...

I'm no great expert on this stuff however, so anyone is welcome to speak up if 
it's not a good way to do it!


-----Original Message-----
From: flexcoders@yahoogroups.com on behalf of Merrill, Jason
Sent: Fri 18/01/2008 12:46
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Drawn objects acting as children to components?
 
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 




______________________________________________________________________
This communication is from Primal Pictures Ltd., a company registered in 
England and Wales with registration No. 02622298 and registered office: 4th 
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT 
registration No. 648874577.

This e-mail is confidential and may be privileged. It may be read, copied and 
used only by the intended recipient. If you have received it in error, please 
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 
1010. Please then delete the e-mail and do not disclose its contents to any 
person.
This email has been scanned for Primal Pictures by the MessageLabs Email 
Security System.
______________________________________________________________________

<<winmail.dat>>

Reply via email to