说说它俩的区别:
使用visible = false: 使得该对象不可见,但是它依然占据着那个位置。
使用includeInLayout = false :该对象的位置将会被后面的对象补上
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ private function includeInLayoutClick():void{ if(this.btn1.includeInLayout == false){ this.btn1.includeInLayout = true ; }else{ this.btn1.includeInLayout = false ; } } private function visibleClick():void{ if(this.btn2.visible == false){ this.btn2.visible = true ; }else{ this.btn2.visible = false ; } } ]]> </mx:Script> <mx:HBox width="100%" height="300"> <mx:Button id="btn1" label="Button1"/> <mx:Button id="btn2" label="Button2"/> <mx:Button id="btn3" label="Button3"/> <mx:Button id="btn4" label="Button4"/> </mx:HBox> <mx:Button x="29" y="308" label="includeInLayout" click="includeInLayoutClick()"/> <mx:Button x="189" y="308" label="visible" click="visibleClick()"/> </mx:Application>