<mx:HBoxxmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ import mx.core.Container; import mx.core.UIComponent; override protectedfunction measure():void { super.measure(); var childrenWidth:int = 0; var childrenHeight:int = 0; //loop through all children, and determine the height and width //of all the children components for(var i:int = 0; i<this.numChildren; i++) { var obj:UIComponent = (getChildAt(i) as UIComponent); if(obj is Container) { //here we are using the viewMetricsAndPadding //so that we get any style information affiliated //with the child as well as its actual width childrenWidth += Container(obj).viewMetricsAndPadding.left+ Container(obj).viewMetricsAndPadding.right+obj.width; childrenHeight += Container(obj).viewMetricsAndPadding.top+ Container(obj).viewMetricsAndPadding.bottom+obj.height; }e else { childrenWidth += obj.width; childrenHeight += obj.height; } } //set this components measured height based on our calculations measuredHeight = childrenHeight; measuredWidth = childrenWidth; }