Flex4 动态添加删除组件
2011-08-24 10:15
615 查看
private function creatCombox(IdName:String):void{ var comSeleCriteriaTemp:ComboBox=new ComboBox; bcSelectionCriteria.addElement(comSeleCriteriaTemp); comSeleCriteriaTemp.id="comSeleCriteria"+IdName; comSeleCriteriaTemp.name="comSeleCriteria"+IdName; comSeleCriteriaTemp.styleName="dropDownList1"; comSeleCriteriaTemp.dataProvider=comSeleCriteria.dataProvider; comSeleCriteriaTemp.width=comSeleCriteria.width; comSeleCriteriaTemp.height=comSeleCriteria.height; comSeleCriteriaTemp.selectedIndex=0; comSeleCriteriaTemp.x=comSeleCriteria.x; comSeleCriteriaTemp.y=55+30*tempAddDelete; var comConditionTemp:ComboBox=new ComboBox; bcSelectionCriteria.addElement(comConditionTemp); comConditionTemp.id="comCondition"+IdName; comConditionTemp.name="comCondition"+IdName; comConditionTemp.styleName="dropDownList1"; comConditionTemp.dataProvider=comCondition.dataProvider; comConditionTemp.width=comCondition.width; comConditionTemp.height=comCondition.height; comConditionTemp.selectedIndex=0; comConditionTemp.x=comCondition.x; comConditionTemp.y=55+30*tempAddDelete; var txtValueTemp:TextInput=new TextInput(); bcSelectionCriteria.addElement(txtValueTemp); txtValueTemp.id="txtValue"+IdName; txtValueTemp.name="txtValue"+IdName; txtValueTemp.width=txtValue.width; txtValueTemp.height=txtValue.height; txtValueTemp.x=txtValue.x; txtValueTemp.y=55+30*tempAddDelete; var btnGetValueTemp:Button =new Button; bcSelectionCriteria.addElement(btnGetValueTemp); btnGetValueTemp.label="GET VALUE"; btnGetValueTemp.id="btnGetValue"+IdName; btnGetValueTemp.name="btnGetValue"+IdName; btnGetValueTemp.width=btnGetValue.width; btnGetValueTemp.height=btnGetValue.height; btnGetValueTemp.styleName="button1"; btnGetValueTemp.x=btnGetValue.x; btnGetValueTemp.y=55+30*tempAddDelete; var btnAddTemp:Button =new Button; bcSelectionCriteria.addElement(btnAddTemp); btnAddTemp.label="ADD"; btnAddTemp.id="btnAdd"+IdName; btnAddTemp.name="btnAdd"+IdName; btnAddTemp.width=btnAdd.width; btnAddTemp.height=btnAdd.height; btnAddTemp.styleName="button1"; btnAddTemp.x=btnAdd.x; btnAddTemp.y=55+30*tempAddDelete; btnAddTemp.addEventListener(MouseEvent.CLICK,btnAdd_clickHandler) var btnDeleteTemp:Button =new Button; bcSelectionCriteria.addElement(btnDeleteTemp); btnDeleteTemp.label="DELETE"; btnDeleteTemp.id="btnDelete"+IdName; btnDeleteTemp.name="btnDelete"+IdName; btnDeleteTemp.width=btnDelete.width; btnDeleteTemp.height=btnDelete.height; btnDeleteTemp.styleName="button1"; btnDeleteTemp.x=btnDelete.x; btnDeleteTemp.y=55+30*tempAddDelete; btnDeleteTemp.addEventListener(MouseEvent.CLICK,btnDelete_clickHandler) }
protected function btnDelete_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub var tempDel:IVisualElement= event.currentTarget as IVisualElement; var tempY:int=tempDel.y; var tempCount:int=bcSelectionCriteria.numElements; var tempIndex:int=bcSelectionCriteria.getElementIndex(tempDel); bcSelectionCriteria.removeElement(bcSelectionCriteria.getElementAt(tempIndex)); bcSelectionCriteria.removeElement(bcSelectionCriteria.getElementAt(tempIndex-1)); bcSelectionCriteria.removeElement(bcSelectionCriteria.getElementAt(tempIndex-2)); bcSelectionCriteria.removeElement(bcSelectionCriteria.getElementAt(tempIndex-3)); bcSelectionCriteria.removeElement(bcSelectionCriteria.getElementAt(tempIndex-4)); bcSelectionCriteria.removeElement(bcSelectionCriteria.getElementAt(tempIndex-5)); tempCount=bcSelectionCriteria.numElements; for(var i:int=0;i<tempCount;i++) { if(bcSelectionCriteria.getElementAt(i).y>tempY) { bcSelectionCriteria.getElementAt(i).y-=30; } } }
添加和删除功能
相关文章推荐
- 在Vue组件上动态添加和删除属性方法
- 在Vue组件上动态添加和删除属性
- Flex中如何使用addChild()和removeChild()函数动态添加或删除Accordion容器中项目的例子
- Flex之旅:第二部分:容器与布局(2)---动态添加组件(TabNavigator)
- 第14篇:angular动态添加和删除组件元素的封装函数
- 关于wxpython的ScrolledWindow组件在动态添加删除组件时Sizer出现的Layout问题
- Flex动态添加组件例子 Flex如何动态添加组件
- Flex动态添加组件例子 Flex如何动态添加组件
- Extjs4.2 MVC 动态添加删除组件
- Android学习一——动态添加组件与删除,可见性设置,imagebutton简单使用
- [Flex] Accordion系列-动态添加或删除Accordion容器中项目
- swing中动态添加、删除组件,像js中的createElement一样
- 动态添加组件到flex的可折叠容器中
- Android实战简易教程<十一>(树形组件:ExpandableListView显示和动态添加删除)
- Android实战简易教程-第十一枪(树形组件:ExpandableListView显示和动态添加删除)
- Spring整合Quartz实现动态定时器,相关api,定时器添加,删除,修改
- Windows Server 2003 添加/删除Windows组件出现错误的问题
- Windows Server 2003 添加/删除Windows组件出现错误的问题
- Windows Server 2003 添加/删除Windows组件出现错误的问题
- jquery动态添加或删除表(table)的行(tr)