Apache flex Flex 4动态调整父容器的大小以包含子容器

Apache flex Flex 4动态调整父容器的大小以包含子容器,apache-flex,mxml,flex4,Apache Flex,Mxml,Flex4,当父容器(如组)的子容器调整大小时,是否有一种简单的方法可以使其调整大小 下面是一个小示例应用程序。当我把200x200“食物”放在“胃”中时,胃&它包含100x100“身体”应该调整大小以容纳食物 有什么想法吗 (摘自本要点) 好的,这是flex 4 sdk中的一个bug,已经修复。太棒了 发件人: 你的例子在最近的一次调查中对我很有用 建造。也许这是一个老房子里的虫子 建造。每晚尝试一种新的 构建: -瑞安 显然,这有点太晚了,但是您可以重写addElementAt方法并添加一些调整大小的

当父容器(如组)的子容器调整大小时,是否有一种简单的方法可以使其调整大小

下面是一个小示例应用程序。当我把200x200“食物”放在“胃”中时,胃&它包含100x100“身体”应该调整大小以容纳食物

有什么想法吗

(摘自本要点)


好的,这是flex 4 sdk中的一个bug,已经修复。太棒了

发件人:

你的例子在最近的一次调查中对我很有用 建造。也许这是一个老房子里的虫子 建造。每晚尝试一种新的 构建:

-瑞安


显然,这有点太晚了,但是您可以重写addElementAt方法并添加一些调整大小的功能。下面,您可以看到应该/可以如何重写AddElementAddd()

//This would be placed in a custom component that extends Group. Your stomach would be this component.
override public function addElementAt(element:IVisualElement, index:int):IVisualElement
{
    super.addElementAt(element, index);

    ChangeWatcher.watch(element, "width", function():void{ resizeHandler(element) });
    ChangeWatcher.watch(element, "height", function():void{ resizeHandler(element) });
}

private function resizeHandler(el:IVisualElement):void
{
    var element:DisplayObject = el as DisplayObject;

    //Rest of the resizing code.
}
我知道这适用于flex3和Canvas,所以它也适用于flex4和Group

//This would be placed in a custom component that extends Group. Your stomach would be this component.
override public function addElementAt(element:IVisualElement, index:int):IVisualElement
{
    super.addElementAt(element, index);

    ChangeWatcher.watch(element, "width", function():void{ resizeHandler(element) });
    ChangeWatcher.watch(element, "height", function():void{ resizeHandler(element) });
}

private function resizeHandler(el:IVisualElement):void
{
    var element:DisplayObject = el as DisplayObject;

    //Rest of the resizing code.
}