Flex如何真正隐藏一个组件
2013-12-08 19:59
381 查看
大家一定会认为是使用myComponent.visible = false;,但实际上它并不能如你所愿。如果其父元素为VBox或HBOX ,那么会有一个间隙。你可以设置它的Height为0,但仍要注意verticalGap和horizontalGap。
解决方法是visible和includeInLayout 一起使用,详见代码:
程序代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical">
<mx:states>
<mx:State name="hideText">
<mx:SetProperty target="{myText}"
name="includeInLayout" value="false" />
<mx:SetProperty target="{myText}"
name="visible" value="false" />
</mx:State>
</mx:states>
<mx:Button label="hide text"
click="currentState = 'hideText'" />
<mx:Text id="myText" text="hello, this text will
be hidden or shown, depending on the buttons" />
<mx:Button label="show text"
click="currentState = ''" />
</mx:Application>
解决方法是visible和includeInLayout 一起使用,详见代码:
程序代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical">
<mx:states>
<mx:State name="hideText">
<mx:SetProperty target="{myText}"
name="includeInLayout" value="false" />
<mx:SetProperty target="{myText}"
name="visible" value="false" />
</mx:State>
</mx:states>
<mx:Button label="hide text"
click="currentState = 'hideText'" />
<mx:Text id="myText" text="hello, this text will
be hidden or shown, depending on the buttons" />
<mx:Button label="show text"
click="currentState = ''" />
</mx:Application>
相关文章推荐
- 在FLEX中真正的隐藏一个组件,隐藏后不占据自身的位置.
- flex如何真是隐藏一个组件
- 在FLEX中真正的隐藏一个组件,隐藏后不占据自身的位置. (转)
- Flex中如何隐藏一个组件
- 在FLEX中真正的隐藏一个组件,隐藏后不占据自身的位置. (转)
- 如何成为一个真正在路上的Linuxer
- Flex动态添加组件例子 Flex如何动态添加组件
- 如何把.rar文件隐藏在一个图片内
- Flex中如何创建一个具有良好排序效果的TileList
- Flex中如何利用PopUpManager类创建一个弹出Image控件的例子
- 如何隐藏一个程序在任务栏上图标
- Flex中如何通过addChild()函数在List中显示一个Sprite的例子
- 如何做一个avalon组件
- Flex中如何通过设置tickLength样式设定HSlider控件上一个标记号(tick)长度的例子
- 如何在自己的信息管理系统里集成第三方权限控制组件 - 开发一个好用稳定的开放组件
- 从”如何设计一个通用数据类型的数组“谈什么才是程序员真正应该干的事
- 如何在unity游戏运行过程中给GameObject添加一个组件
- FLEX 4里如何隐藏超出BorderContainer大小的内容
- 真正能做一个经得起考验的产品化软件组件需要要多年的积累及突破一个个境界才可有希望
- 自定义真正的可重用Flex组件