Greg: A few things if you are interested. In the measure function, instead of setting minHeight and minWidth, you should consider setting measuredMinWidth and measuredMinHeight.
Every square you add in createChildren, will later be available via the getChildAt( index ) method. So, if you wanted to go a bit further, it would be good to call setActualSize on your objects in updateDisplayList. It is a minor point in what you are doing here due to the static nature of the square size. However, it would set things up a little better for you should you ever want to extend this component or add functionality to it. Just my 2 cents. Take care, Mike --- In [email protected], "greg h" <[EMAIL PROTECTED]> wrote: > > Mike, > > Thank you very much for your guidance. > > I dug deeper and got the component fully functional. > > Following is the cleaned up code. > > Again, thanks for your prompt and authoritative response. > > Warmest regards, > > g > > > package > { > import flash.events.Event; > > import mx.core.UIComponent; > import mx.events.FlexEvent; > > public class MyComp extends UIComponent > { > public var squareSize:uint = 10; > public var squaresTotal:uint = 13; > public var color:uint = 0xf8b34e; > > private var currentAlpha:Number = 1.0; > private var square:UIComponent = new UIComponent(); > > > public function MyComp() > { > super(); > > } > > override protected function measure():void > { > super.measure(); > > var width:Number = (squareSize*squaresTotal)+( > (0.25*squareSize)*(squaresTotal-1)); > measuredWidth=width; > minWidth=width; > measuredHeight=squareSize; > minHeight=squareSize; > } > > override protected function createChildren():void > { > super.createChildren(); > > square.graphics.beginFill(color, 1); > square.graphics.drawRect(0, 0, squareSize, squareSize); > square.graphics.endFill(); > square.alpha = currentAlpha; > this.addChild(square); > for (var i:Number=1; i<(squaresTotal); i++) > { > square = new UIComponent(); > currentAlpha = 1.0 - (i * 1/squaresTotal) ; > square.graphics.beginFill(color, 1); > square.graphics.drawRect( (squareSize*1.25*i), 0, > squareSize, squareSize); > square.graphics.endFill(); > square.alpha = currentAlpha; > square.setActualSize(squareSize, squareSize); > this.addChild(square); > } > } > > } > } >
