flex4控件联动显示与隐藏效果
来源:互联网 发布:中国制造业数据 编辑:程序博客网 时间:2024/05/21 10:24
在flex的开发过程中,有一种类似这样的效果,比如,我想选择不同的日期查询效果(按年,月,日,范围),然后联动不同的控件查询条件。在这种情况下,使用如下代码,即可做到显示与隐藏:
隐藏:
includeInLayout="false" visible="false"
显示:
includeInLayout="true" visible="true"
例子,如下所示:
1.选择控件以及它的处理函数:
<s:HGroup> <mx:Label text="按时间:" height="29"/> <s:DropDownList id="selectType" horizontalCenter="31" top="20" selectedIndex="1" change="day_change(event);" width="126"> <s:dataProvider> <s:ArrayList source="[全部,按日,按月,按年,按时间范围]" /> </s:dataProvider> </s:DropDownList> </s:HGroup>
2.被选择和处理的控件列表:
<!--按日--> <mx:Label id="selectTime" text="选择时间"/> <mx:DateField id="select_date" formatString="YYYY-MM-DD" selectedDate="{new Date()}" enabled="true" visible="true" /> <mx:Button id="manualSetBtn" label="手动计算当天节能率" click="manualSetBtn_clickHandler(event)" height="24" width="132"/> <mx:Label id="toSelect" text="至" visible="false" includeInLayout="false"/> <mx:DateField id="selectTo_date" formatString="YYYY-MM-DD" selectedDate="{new Date()}" visible="false" includeInLayout="false"/> <!--按月--> <s:NumericStepper id="select_year" minimum="2012" maximum="2112" horizontalCenter="60" verticalCenter="0" visible="false" includeInLayout="false" width="62" change="numberValueChange(event)"/> <mx:Label text="年" id="select_yearLabel" visible="false" includeInLayout="false"/> <s:NumericStepper id="select_month" minimum="1" maximum="12" horizontalCenter="86" verticalCenter="0" visible="false" includeInLayout="false" width="53" change="numberValueChange(event)"/> <mx:Label text="月" id="select_monthLabel" visible="false" includeInLayout="false"/> </s:HGroup><s:Button label="查询" click="button2_clickHandler(event)"/> <mx:Button textAlign="center" label="导出" click="button3_clickHandler(event)"/>
相应的处理函数
/** * 执行时间的改变相应事件 */private function day_change(evt:Event):void {var rb:DropDownList = evt.currentTarget as DropDownList;//根据选择的不同呈现的控件也不同if(rb.selectedIndex == 0){selectTime.visible = false;select_date.visible = false;select_date.includeInLayout = false;manualSetBtn.visible = false;manualSetBtn.includeInLayout = false;select_year.visible = false;select_year.includeInLayout = false;select_yearLabel.visible = false;select_yearLabel.includeInLayout = false;select_month.visible = false;select_month.includeInLayout = false;select_monthLabel.visible = false;select_monthLabel.includeInLayout = false;selectTo_date.visible = false;selectTo_date.includeInLayout = false;toSelect.visible = false;toSelect.includeInLayout = false;}if(rb.selectedIndex==1){selectTime.visible = true;select_date.visible = true;select_date.includeInLayout = true;manualSetBtn.visible = true;manualSetBtn.includeInLayout = true;select_year.visible = false;select_year.includeInLayout = false;select_yearLabel.visible = false;select_yearLabel.includeInLayout = false;select_month.visible = false;select_month.includeInLayout = false;select_monthLabel.visible = false;select_monthLabel.includeInLayout = false;selectTo_date.visible = false;selectTo_date.includeInLayout = false;toSelect.visible = false;toSelect.includeInLayout = false;}else if(rb.selectedIndex==2){selectTime.visible = true;select_date.visible = false;select_date.includeInLayout = false;manualSetBtn.visible = false;manualSetBtn.includeInLayout = false;select_year.visible = true;select_year.includeInLayout = true;select_yearLabel.visible = true;select_yearLabel.includeInLayout = true;select_month.visible = true;select_month.includeInLayout = true;select_monthLabel.visible = true;select_monthLabel.includeInLayout = true;selectTo_date.visible = false;selectTo_date.includeInLayout = false;toSelect.visible = false;toSelect.includeInLayout = false;}else if(rb.selectedIndex==3){selectTime.visible = true;select_date.visible = false;select_date.includeInLayout = false;manualSetBtn.visible = false;manualSetBtn.includeInLayout = false;select_year.visible = true;select_year.includeInLayout = true;select_yearLabel.visible = true;select_yearLabel.includeInLayout = true;select_month.visible = false;select_month.includeInLayout = false;select_monthLabel.visible = false;select_monthLabel.includeInLayout = false;selectTo_date.visible = false;selectTo_date.includeInLayout = false;toSelect.visible = false;toSelect.includeInLayout = false;}else if(rb.selectedIndex==4){selectTime.visible = true;select_date.visible = true;select_date.includeInLayout = true;manualSetBtn.visible = false;manualSetBtn.includeInLayout = false;select_year.visible = false;select_year.includeInLayout = false;select_yearLabel.visible = false;select_yearLabel.includeInLayout = false;select_month.visible = false;select_month.includeInLayout = false;select_monthLabel.visible = false;select_monthLabel.includeInLayout = false;selectTo_date.visible = true;selectTo_date.includeInLayout = true;toSelect.visible = true;toSelect.includeInLayout = true;}}
这样就可以实现不同的查询条件,联动不同控件的显示与隐藏效果。
(完,待续..........................)
- flex4控件联动显示与隐藏效果
- jquery效果-隐藏与显示
- jQuery显示与隐藏效果
- 控件隐藏/显示时的动画效果
- [Android] View控件显示隐藏动画效果
- View控件的显示和隐藏效果
- display 显示与隐藏控件
- Android控件显示与隐藏
- Android 控件显示与隐藏
- Android控件显示与隐藏
- dropdownlist之间的互相联动(显示与隐藏)
- jQuery效果之显示与隐藏
- 切换CSS3实现隐藏与显示效果
- swt/jface控件的隐藏与显示
- swt/jface控件的隐藏与显示
- Android控件的隐藏与显示
- 【1】Android控件的显示与隐藏
- iOS控件的动画显示与隐藏
- Java读取excel
- linux 下使用命令行开发 Android 应用程序
- 产品生产的各个阶段:DV,EV,PV ········是什么意思
- 流血冲突已造成叙上万人死亡
- OpenStack对象存储——Swift
- flex4控件联动显示与隐藏效果
- Hadoop Mapreduce优先级调度
- hadoop完全分布式过程中遇到的一些问题和总结
- Linux 7天系列 Day 2(转)
- mysql日期加秒、天、月
- 工作中linux上装数据库经常用到的命令
- Android应用程序键盘(Keyboard)消息处理机制分析
- LinkedIn用户平均收入远超Facebook
- ibatis案例1