Flex combox 테스트

7837 단어 xmlFlex
<?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" creationComplete="init()">

<fx:Declarations>
<!-- ( 、 ) -->
</fx:Declarations>

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.IList;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
[Bindable]
private var monitorItemData:XML=<root>
<node label=" " type="0">
<item label="apache" value="1"/>
<item label="loadbalance" value="2"/>
                   </node>
<node label=" " type="0">
<item label="apusic" value="1"/>
<item label="tomcat" value="2"/>
<item label="weblogic" value="3"/>
</node>
<node label=" " type="0">
<item label="mysql" value="1"/>
<item label="db2" value="2"/>
<item label="oracle" value="3"/>
</node>

</root>;

var data:ArrayCollection = new ArrayCollection();
var provider:ArrayCollection;
var xmlListCollection:XMLListCollection = new XMLListCollection();
var selectedVm:String;
var selectedSpecifyItem:String;
var obj:Object;// comboBox

private function init():void{// XML ArrayCollection
xmlListCollection = new XMLListCollection(monitorItemData.children());
    data.source = xmlListCollection.toArray();
// ( ?)
// var xmlList:XMLList = new XMLList();
// xmlList = monitorItemData.elements("node");
// xmlListCollection.source = xmlList;
// var myData:ArrayCollection = new ArrayCollection(xmlListCollection.toArray());

             }

private function vmChangeHandler(e:Event):void{
var xmlListCollection:XMLListCollection = new XMLListCollection();
xmlListCollection.source = e.target.selectedItem.item;// XMLList XMLListCollection

provider = new ArrayCollection(xmlListCollection.toArray());
specifyItem.dataProvider = provider;
//specifyItem.selectedIndex=0; comboBox
selectedVm = e.target.selectedItem.@label;
specifyItem.selectedIndex = -1;
         }

private function specifyItemChangeHandler(e2:Event):void{
selectedSpecifyItem = specifyItem.selectedItem.@label;
yourSelect.text=selectedVm+selectedSpecifyItem;

}
]]>
</fx:Script>
   
<s:Group width="30%" height="45%" x="153" y="33">
<s:Panel title=" " width="482" height="100%">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Group width="100%" height="20%">
<s:Label text=" :" id="vm" x="33" y="6"/>
<s:ComboBox x="109" y="1" width="124" id="vmCombox"  labelField="@label" dataProvider="{data}" change="vmChangeHandler(event)"/>
<s:Label x="250" y="6" text=" :" id="monitorItem"/>
<s:ComboBox x="311" y="1" width="124" id="specifyItem" labelField="@label" change="specifyItemChangeHandler(event)" />

</s:Group>
<s:Line width="100%" height="2">
<s:stroke>
<s:SolidColorStroke color="0x000000" weight="2"/>
</s:stroke>
</s:Line>
<s:Group width="100%" height="66%" id="drop">
<s:Label text=" :" id="selectedItems" x="10" y="0"/>
<s:List height="153" width="161" x="105" y="0">
</s:List>

<s:Button label=" " x="278" y="34"/>

<s:Button x="277" y="83" label=" " id="dropAll"/>
           </s:Group>
<s:Line width="100%" height="2">
<s:stroke>
<s:SolidColorStroke color="0x000000" weight="2"/>
</s:stroke>
</s:Line>
<s:Group width="100%" height="14%">
<s:Button label=" " x="308" y="-4" id="submit"/>
<s:Button x="400" y="-4" label=" " id="cancel"/>
<s:Label x="38" y="-1" text=" :"/>
<s:Label x="128" y="0" id="yourSelect"/>
</s:Group>
</s:Panel>
</s:Group>
</s:Application>

—————————————————————— ————————————

1、 init() ?
2、 vmChangeHandler specifyItem.selectedIndex=0
3、 comboBox tree

—————————————— ——————————————
<?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"
   creationComplete="init()">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- ( 、 ) -->
<fx:XML id="xmlPC_linked" source="PC_linked.xml"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;

var xmlListCollection:XMLListCollection = new XMLListCollection();
var data:ArrayCollection;// = new ArrayCollection();
var xmlList:XMLList = new XMLList();

public function init():void{
//xmlListCollection = new XMLListCollection(xmlPC_linked.children());
//data.source = xmlListCollection.toArray();
    xmlList = xmlPC_linked.elements("node");
xmlListCollection.source = xmlList;
data = new ArrayCollection(xmlListCollection.toArray());
}

public function changeHandler(e:Event):void
{  
//showSelectedItem.text = ComboBox(e.target).selectedItem.node.label;

city.dataProvider=e.target.selectedItem.item;
city.selectedIndex=0;              
}
]]>
</fx:Script>
<s:Panel  x="262" y="144" width="296" height="200">
<s:ComboBox id="pro" dataProvider="{data}" labelField="@label" change="changeHandler(event)"/>
        <s:ComboBox id="city" labelField="@label"/>
</s:Panel>
</s:Application>
mxml xml , 。 mxml flex3 ...  ...

  ...  ... 

좋은 웹페이지 즐겨찾기