<?xml version=”1.0″ encoding=”utf-8″?> <!— サンプル画面 –> <mx:Application xmlns:fx=”http://ns.adobe.com/mxml/2009“ xmlns:s=”library://ns.adobe.com/flex/spark” xmlns:mx=”library://ns.adobe.com/flex/mx” minWidth=”800″ minHeight=”400″> <fx:Script> <![CDATA[ import mx.controls.Alert; // import flash.events.Event; import mx.collections.ArrayCollection; //下拉框的数据集 [Bindable] public static var fileNameTypeDropDownList:ArrayCollection=new ArrayCollection([{id: 0, label: ‘Flag文件’}, {id: 1, label: ‘固定文件名’}, {id: 2, label: ‘正则表达式’}]);
//获取DropDownList选中元素的索引 public static function getSelectedIndexByResult(list:ArrayCollection, key:String, result:Object):int { var selectedIndex:int=0; try { for (var i:int=0; i < list.length; i++) { if (list[i][key] == result) { selectedIndex=i; break; } } } catch (e:Error) { Alert.show(e.message); } return selectedIndex; } // var index:int=getSelectedIndexByResult(fileNameTypeDropDownList, ‘id’, data[‘file_name’]) ]]> </fx:Script> <s:Group id=”contentsBody” styleName=”contentsBody” width=”100%”> <s:VGroup id=”viewId” styleName=”viewId” width=”100%” horizontalAlign=”right”> </s:VGroup> <s:DropDownList id=”userGroupComboBox” requireSelection=”true” dataProvider=”{fileNameTypeDropDownList}” click=”getSelectedIndexByResult(fileNameTypeDropDownList, ‘id’, data[‘file_name’])”/> </s:Group>
</mx:Application>
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/183339.html原文链接:https://javaforall.cn