Get rid of the VBox for now.  x,y have no meaning in a VBox.
 
You shouldn't need to create an inner sprite either, but you should set
the center of the circle to be far enough in that the circle doesn't end
up at negative coordinates.

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Merrill, Jason
Sent: Thursday, January 17, 2008 4:49 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Drawn objects acting as children to
components?



OK, I'm about 80% there now.  However, the graphic appears at location
0,0 in the panel and extends outside the panel boundaries.  I set the
params in MXML like this:
 
      <mx:Panel id="networkBrowserPanel" width="100%" height="100%"
layout="absolute" title="Network" >
       <mx:VBox horizontalAlign="left">
            <c:NetworkLayout outerAlpha="1" innerAlpha="1"
outerColor="#ffffff" innerColor="0x666666" x="230" y="240"
graphicRadius="20" container="{networkBrowserPanel}" />
        </mx:VBox>
       </mx:Panel>
 
Here is the AS component class I wrote:
 
package components
{
 import mx.core.UIComponent;
 import flash.geom.Rectangle;
 import mx.containers.Panel;
 import flash.display.Sprite;
 
 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 graphicX:int;
  public var graphicY:int;
  public var graphicRadius:int;
  
  private var _sprite:Sprite;
  
  public function NetworkLayout()
  {
   super();
  }
 
        override protected function commitProperties():void
        {
           drawCircle();
        }
 
        override protected function measure():void
        {
         var rect:Rectangle = getBounds(container);
         measuredWidth = rect.width;
           measuredHeight = rect.height;
        }
        
        private function drawCircle():void
        {
            _sprite = new Sprite();
            _sprite.graphics.lineStyle(borderThickness, outerColor,
outerAlpha);
           _sprite.graphics.beginFill(innerColor, innerAlpha)
           _sprite.graphics.drawCircle(graphicX, graphicY,
graphicRadius); 
           addChild(_sprite);
        }
 }
}

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