flex的box中button的布局动态控制

同一个页面工具栏,要在不同的功能模块下显示不同的按钮,不能直接删除该空间,否则一些方法里用到这些控件,程序报错。但是需要根据模块功能动态隐藏一些,只用btntest1.visible=false,该控件所占的位置为一段空白,必须同时设置btntest1.includeInLayout=false,才能既隐藏控件又释放了其所占的空间。
如果用了box来布局所有功能按钮,作为一个工具栏,必须注意它的autoLayout="false" 会影响单独的btn 的隐藏并释放所占空间的功能,所以这个属性切忌不要false.
我今天用单独的btn,都没有问题,就是放到box不行,后来发现是这个属性捣乱。

testbtn后自动隐藏test2并释放所占空间;但是testbtn1控制的box设置了autoLayout属性,test12所占空间没有释放!
示例:
private function onclick():void
{
test2.includeInLayout=false;
test3.visible=true;
}
private function onclick1():void
{
test12.includeInLayout=false;
test13.visible=true;
}
...
<mx:Button id="testbtn" label="testbtn" width="80" click="onclick()" y="100">
</mx:Button>
<mx:Button id="testbtn1" label="testbtn1" width="80" click="onclick1()" x="100" y="100">
</mx:Button>
<mx:Box y="120" height="35" width="100%" direction="horizontal" >
<mx:Button id="test1" label="test1" width="100" height="30" visible="true" toolTip="test1" />
<mx:Button id="test2" label="test2" width="100" height="30" visible="false" toolTip="test2" />
<mx:Button id="test3" label="test3" width="100" height="30" visible="false" toolTip="test3" />
<mx:Button id="test4" label="test4" width="100" height="30" visible="true" toolTip="test4" />

<mx:ComboBox width="200">
</mx:ComboBox>
</mx:Box>
<mx:Box y="180" height="35" width="100%" direction="horizontal" horizontalGap="0" autoLayout="false">
<mx:Button id="test11" label="test1" width="100" height="30" visible="true" />
<mx:Button id="test12" label="test2" width="100" height="30" visible="false" />
<mx:Button id="test13" label="test3" width="100" height="30" visible="false" />
<mx:Button id="test14" label="test14" width="100" height="30" visible="true" />

<mx:ComboBox width="200">
</mx:ComboBox>
</mx:Box>
...
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值