<?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>