Button按钮隐藏控制通过visible属性实现,visible属性取值有两种:true/false;以下是几种隐藏控制是实现:
第一种:直接设置visible属性:
1 <mx:Button width="55" height="25" label="登录" click="loginSystem()" visible="false"/>
第二种:实现动态控制:通过Button的id控制
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:page="pager.*" width="100%" height="100%" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" layout="absolute" verticalAlign="top" horizontalAlign="center" pageTitle="按钮隐藏控制" creationComplete="treeData()"> <mx:Style source="skins/blue/blue.css"/> <mx:Script> <![CDATA[ private function treeData():void{ if(...){ button.visible = false; //第一种方式 }else if(...){ button.setVisible(false,false); //第二种方式 } } private function loginSystem():void{ } ]]> </mx:Script> <mx:Panel height="100%" width="100%" > <mx:Button id="button" width="55" height="25" label="登录" click="loginSystem()"/> </mx:Panel> </mx:Application>
第三种:设置visible的值为一个变量:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:page="pager.*" width="100%" height="100%" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" layout="absolute" verticalAlign="top" horizontalAlign="center" pageTitle="按钮隐藏控制" creationComplete="treeData()"> <mx:Style source="skins/blue/blue.css"/> <mx:Script> <![CDATA[ private function treeData():void{ if(...){ deptbuttontype = true;
}else { deptbuttontype = false; } } private function loginSystem():void{ } ]]> </mx:Script> <mx:Panel height="100%" width="100%" > <mx:Button id="button" width="55" height="25" label="登录" click="loginSystem()" visible="{deptbuttontype}/> </mx:Panel> </mx:Application>