zoukankan      html  css  js  c++  java
  • Flex combox labelFunction 使用示例

    <?xml version="1.0" encoding="utf-8"?>
    
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    				layout="vertical"
    				verticalAlign="middle"
    				backgroundColor="white">
    	
    	<mx:Script>
    		<![CDATA[
    			import mx.utils.StringUtil;
    			import mx.controls.Alert;
    			
    			[Bindable]
    			private var arr:Array=[
    				{name:"名字11",abbrev:"Al1"},
    				{name:"名字12",abbrev:"Al2"},
    				{name:"名字13",abbrev:"Al3"},
    				{name:"名字14",abbrev:"Al4"},
    			];
    			
    			private function comboBox_labelFunc(item:Object):String {
    				return StringUtil.substitute("{0} ({1})", item.@name, item.@abbrev);
    			}
    			
    			private function comboBox_labelFunc_custom(item:Object):String {
    				return StringUtil.substitute("{0} ({1})", item.name, item.abbrev);
    			}
    			
    			
    			protected function button1_clickHandler(event:MouseEvent):void
    			{
    				if(this.comboBox2.selectedItem)
    					Alert.show(this.comboBox2.selectedItem.name);
    				else Alert.show("not selected");
    				
    				if(this.comboBox.selectedItem)
    					Alert.show(this.comboBox.selectedItem.@name);
    				else Alert.show("not selected");
    				
    			}
    			
    		]]>
    	</mx:Script>
    	
    	<mx:XMLList id="statesXMLList">
    		<state abbrev="AL" name="Alabama" />
    		<state abbrev="AK" name="Alaska" />
    		<state abbrev="AZ" name="Arizona" />
    		<state abbrev="AR" name="Arkansas" />
    		<state abbrev="CA" name="California" />
    		<state abbrev="CO" name="Colorado" />
    		<state abbrev="CT" name="Connecticut" />
    	</mx:XMLList>
    	<mx:ComboBox id="comboBox2"
    				 prompt="Please select a aa..."
    				 dataProvider="{arr}"
    				 labelFunction="comboBox_labelFunc_custom" />
    	<mx:Button label="按钮" click="button1_clickHandler(event)"/>
    	
    	<mx:ComboBox id="comboBox"
    				 prompt="Please select a State..."
    				 dataProvider="{statesXMLList}"
    				 labelFunction="comboBox_labelFunc" />
    	
    	
    	
    </mx:Application>
    

      

  • 相关阅读:
    软件开发项目文档模版
    Java Swing 非常漂亮的外观Nimbus使用方法
    周00王总监 宁波浦一的同仁们 有看见的进来
    冰川世界
    君住长江头,我住长江尾,日日思君不见君,共饮长江水
    可乐男孩被保送上大学
    变形金刚2
    爱无罪
    英语习惯口语简写
    看完了团长,我没有心理在去看《南京!南京!》
  • 原文地址:https://www.cnblogs.com/wucg/p/2139678.html
Copyright © 2011-2022 走看看