flex3 combobox的数据源以及相关数据取得的代码

仅供参考,欢迎指正,谢谢

相关的xml文件位置:assets/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
 <error_reason>全部</error_reason>
 <error_reason>部分1</error_reason>
 <error_reason>部分2</error_reason>
 <error_reason>部分3</error_reason>
 <error_reason>部分4</error_reason>
 <error_reason>部分5</error_reason>
 <error_reason>部分6</error_reason>
</config>

 

相关的mxml的应用程序

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
 <mx:Script>
  <![CDATA[
   import mx.controls.ComboBox;
   import mx.events.DropdownEvent;
   import mx.collections.ArrayCollection;
   import mx.rpc.events.ResultEvent;
   [Bindable]
   private var cbXml:XML=<config>
         <error_reason>全部</error_reason>
         <error_reason>部分1</error_reason>
         <error_reason>部分2</error_reason>
         <error_reason>部分3</error_reason>
         <error_reason>部分4</error_reason>
         <error_reason>部分5</error_reason>
         <error_reason>部分6</error_reason>
           </config>;
   [Bindable]
   private var cbAc:ArrayCollection;
   [Bindable]   
   private var cbXMLByHs:XML;
   [Bindable]
   private var cbAcByDef:ArrayCollection=new ArrayCollection([
   {error_reason:"全部"},
   {error_reason:"部分1"},
   {error_reason:"部分2"},
   {error_reason:"部分3"},
   {error_reason:"部分4"},
   {error_reason:"部分5"},
   {error_reason:"部分6"}
   ]);
   private function initApp():void{
    trace(cbXMLFromUrl);
    cbAc=new ArrayCollection(cbXMLFromUrl.error_reason);
    cbXMLFromHS.send();
   }
   
   private function cbXMLFromHS_resultHandler(event:ResultEvent):void{
    cbXMLByHs=event.result as XML;
    trace(event);
   }
   [Bindable]
   private var showTxt:String="";
   private function closeHandler(event:DropdownEvent):void{
    showTxt=ComboBox(event.target).selectedLabel;
   }
  ]]>
 </mx:Script>
 <mx:Model id="cbXMLFromUrl" source="assets/config.xml"/>
 <mx:HTTPService id="cbXMLFromHS" url="assets/config.xml" result="cbXMLFromHS_resultHandler(event)" resultFormat="e4x"/> 
 <mx:ComboBox x="200" y="77" width="280" height="28" dataProvider="{cbXml.error_reason}" close="closeHandler(event)"></mx:ComboBox>
 <mx:ComboBox x="200" y="132" width="280" height="28" dataProvider="{cbAc}" close="closeHandler(event)"></mx:ComboBox>
 <mx:ComboBox x="200" y="191" width="280" height="28" dataProvider="{cbXMLByHs.error_reason}" close="closeHandler(event)"></mx:ComboBox>
 <mx:ComboBox id="cbbindable" x="200" y="246" width="280" height="28" dataProvider="{cbAcByDef}" labelField="error_reason" close="closeHandler(event)"></mx:ComboBox> 
 <mx:TextInput x="515" y="77" width="280" height="28" text="{'close:'+showTxt}"/>
 <mx:TextInput x="515" y="249" width="280" height="28" text="{cbbindable.text}"/>
</mx:Application>

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ityinluming/article/details/5639050
个人分类: flex
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭