您发现的问题是,普通UIComponent不会向其父级报告宽度或高度值(因为它根本不知道该值应该是什么!)。
measure()
功能。在那里,将measuredWidth和measuredHeight属性设置为UIComponent子级的大小。
override protected function measure():void
{
super.measure();
for(var i:int = 0; i < this.numChildren; i++)
{
var child:DisplayObject = this.getChildAt(i);
this.measuredWidth = Math.max(this.measuredWidth, child.x + child.width);
this.measuredHeight = Math.max(this.measuredHeight, child.y + child.height);
}
}