Flex Demo

<?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" minWidth="955" minHeight="600">
 <s:layout>
  <s:BasicLayout/>
 </s:layout>
 <fx:Declarations>
  <!-- 將非可視元素(例如服務、值對象)放在此處 -->
 </fx:Declarations>
 <fx:Script>
  <![CDATA[
   import mx.binding.utils.BindingUtils;
   import mx.collections.ArrayCollection;
   import mx.collections.ArrayList;
   import mx.controls.Alert;
   import mx.effects.easing.Bounce;
   import mx.events.CloseEvent;
   
   function showOneDialog() : void{
    //    Alert.show("只顯示一個對話框","對話框標題");
    Alert.show("未能查找到任務結果","對話框標題");
   }
   
   protected function showTwoDialog() : void {
    Alert.show("是否確認刪除","確認刪除對話框",1|2,this,deleteEvent);
    
   }
   
   private function deleteEvent(e:CloseEvent) : void {
    trace("ok");
    trace(e.detail.toString()); //在後臺顯示
    Alert.show(e.detail.toString()); //在前臺顯示
   }
   [Bindable]
   var a :ArrayCollection = new ArrayCollection([{label:"從這裏選擇"},{label:"aa"},{label:"bb"},{label:"cc"},{label:"dd"}]);
   
   [Bindable]
   var b :ArrayCollection = new ArrayCollection([{id:"1",j:"aa"},{id:"2",j:"bb"},
    {id:"3",j:"cc"},{id:"4",j:"dd"}]);
   
  ]]>
 </fx:Script>
 <s:Button x="208" y="67" label="顯示一個對話框按鈕" click="showOneDialog()"/>
 <s:Button x="208" y="126" label="顯示兩個對話框按鈕" click="showTwoDialog()"/>
 
 <s:ComboBox id="combobox" x="208" y="286"  dataProvider="{a}" selectedIndex="0"/>
 <mx:DataGrid x="208" y="359" dataProvider="{b}">
  <!--<mx:columns>
  <mx:DataGridColumn headerText="列 1" dataField="col1"/>
  <mx:DataGridColumn headerText="列 2" dataField="col2"/>
  <mx:DataGridColumn headerText="列 3" dataField="col3"/>
  </mx:columns>-->
 </mx:DataGrid>
</s:Application>

注意:ComboBox中的 ArrayCollection 中的key 應爲label否則會被顯示爲object

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章