flex 3 combobox 实现关键字过滤搜索-代码示例

<?xml version="1.0" encoding="utf-8"?> <s: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" viewSourceURL="srcview/index.html" xmlns:myAs="myAs.*" xmlns:wayne="com.wayne.*">    <fx:Script>   <![CDATA[    import mx.collections.ArrayCollection;    import mx.controls.Alert;    import mx.events.DropdownEvent;    import mx.utils.StringUtil;    public var intput_cards:Array= [];        [Bindable]public var cards:Array =      [ {label:"宋江", data:1},      {label:"的李逵", data:2},      {label:"卢俊义", data:3},      {label:"的李逵2", data:4},      {label:"的李逵3", data:5},      {label:"的李逵4", data:6},      {label:"陈江", data:7},      {label:"卢子平", data:8},      {label:"的李逵5", data:9},      {label:"太子", data:10}     ];         private function changeHandler2(event:Event):void {          intput_cards = [];          if(StringUtil.trim(combobox_id.text)==""||StringUtil.trim(combobox_id.text)==null){       combobox_id.dataProvider =  cards;     }else{      for(var i:int = 0; i<cards.length; i++){       if(cards[i].label.indexOf(combobox_id.text , 0)>-1){        intput_cards.push({label:cards[i].label, data:cards[i].data} );       }      }      combobox_id.dataProvider = intput_cards ;     }          combobox_id.validateNow();          combobox_id.open();        } 

   protected function linkbutton1_clickHandler(event:MouseEvent):void    {     // TODO Auto-generated method stub     navigateToURL(new URLRequest("http://blog.csdn.net/kkkloveyou"),"_blank");    }

  ]]>  </fx:Script>    <s:Panel title="ComboBox Sample"      height="100%" width="100%">      <s:VGroup top="20" horizontalCenter="0" >    <s:VGroup>     <s:Label  width="200" color="0x336699" text="Flex3 ComboBox Sample for search:"/>     <mx:ComboBox  id="combobox_id" editable="true" dataProvider="{cards}"  change="changeHandler2(event);"  width="207"   />    </s:VGroup>    <mx:Spacer  height="80"/>       <mx:LinkButton color="red"  label="技术支持:http://blog.csdn.net/kkkloveyou"   click="linkbutton1_clickHandler(event)"/>    </s:VGroup>     </s:Panel>    </s:Application>

flex 3 combobox 实现关键字过滤搜索-代码示例_第1张图片

你可能感兴趣的:(function,Flex,application,library,button,encoding)