---
title: "flex includeInLayout"
author: "demojava"
date: "2012-02-04T22:44:58Z"
tags: []
categories: ["Web前端"]
slug: "flex-includeinlayout"
draft: false
lastmod: "2012-02-04T22:52:44Z"
id: 1393566
url: "https://demojava.iteye.com/blog/1393566"
---

**flex includeInLayout** 隐藏是否参与布局

一般设置组件的visible=false;组件的位置还留着

当希望组件隐藏，同时自动布局清空组件的位置；

**ComponentId.includeInLayout=false;**

```
<mx:VBox>
        <mx:Panel id="p1" 
            title="Panel 1" 
            backgroundColor="#FF0000"/>
        <mx:Panel id="p2" 
            title="Panel 2" 
            backgroundColor="#00FF00"/>
        <mx:Panel id="p3" 
            title="Panel 3" 
            backgroundColor="#0000FF"/>
    </mx:VBox>

    <mx:HBox>
        <mx:Button label="Toggle Panel 2 Visible" 
            click="{p2.visible=!p2.visible;}"/>
        <mx:Button label="Toggle Panel 2 in Layout" 
            click="{p2.includeInLayout=!p2.includeInLayout;}"/>
    </mx:HBox>
```