- <?xml version="1.0" encoding="utf-8"?>
- <mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initComponent()">
- <mx:Script>
- <![CDATA[
- import mx.events.FlexEvent;
- [Bindable]
- private var _label:String;
- [Bindable]
- public var treeSelectedItem:Object;
- public function initComponent():void
- {
- }
- public function updateLabel(event:*):void{
- _label = event.currentTarget.selectedItem[this.labelField];
- treeSelectedItem = event.currentTarget.selectedItem;
- }
- override protected function updateDisplayList(unscaledWidth:Number,
- unscaledHeight:Number):void
- {
- super.updateDisplayList(unscaledWidth, unscaledHeight);
- if(dropdown && _label != null){
- text = _label;
- }
- }
- ]]>
- </mx:Script>
- <mx:dropdownFactory>
- <mx:Component>
- <mx:Tree creationComplete="initTree()" change="outerDocument.updateLabel(event)" showRoot="true" height="500" width="500">
- <mx:Script>
- <![CDATA[
- public function initTree():void {
- var len:int=super.dataProvider.length;
- for(var i:int;i<len;i++)
- {
- super.expandChildrenOf(super.dataProvider[i], true);
- }
- super.selectedItem=outerDocument.treeSelectedItem;
- }
- ]]>
- </mx:Script>
- </mx:Tree>
- </mx:Component>
- </mx:dropdownFactory>
- </mx:ComboBox>
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="components.*">
- <ns1:ComboTree width="300" id="combo" labelField="@label" >
- <mx:XMLListCollection id="MailBox">
- <mx:XMLList>
- <folder label="Mail">
- <folder label="INBOX"/>
- <folder label="Personal Folder">
- <Pfolder label="Business" />
- <Pfolder label="Demo" />
- <Pfolder label="Personal" isBranch="true" />
- <Pfolder label="Saved Mail" />
- </folder>
- <folder label="Sent" />
- <folder label="Trash" />
- </folder>
- <folder label="Mail2">
- <folder label="INBOX2"/>
- <folder label="Personal Folder2">
- <Pfolder label="Business2" />
- <Pfolder label="Demo2" />
- <Pfolder label="Personal2" isBranch="true" />
- <Pfolder label="Saved Mail2" />
- </folder>
- <folder label="Sent2" />
- <folder label="Trash2" />
- </folder>
- </mx:XMLList>
- </mx:XMLListCollection>
- </ns1:ComboTree>
- </mx:Application>