當我將visible屬性設置爲false爲容器中的某個子項時,如何獲取容器的大小?在下面的示例中,當點擊「切換」時,「containerB」被隱藏,但主容器的可滾動區域沒有調整大小。 (我不想通過大量的空白區域滾動。)當兒童的能見度發生變化時調整容器大小?
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function toggle():void {
containerB.visible = !containerB.visible;
}
]]>
</mx:Script>
<mx:VBox height="300" width="200" horizontalAlign="center">
<mx:Button label="Toggle" click="toggle()" width="200"/>
<mx:VBox id="containerA" height="400" width="150" horizontalAlign="center">
<mx:Button label="A" height="400" width="100"/>
</mx:VBox>
<mx:VBox id="containerB" height="400" width="150" horizontalAlign="center">
<mx:Button label="B" height="400" width="100"/>
</mx:VBox>
</mx:VBox>