读书人

关于Flex查询信息并显示的有关问题?那

发布时间: 2012-03-05 11:54:02 作者: rapoo

关于Flex查询信息并显示的问题?那个高手帮忙解答下谢谢了.
这是配置文件的内容所有的信息都从这里取

XML code
<?xml version="1.0" encoding="utf-8"?><root>    <command id="1" label="login" description=" login The HPUX System." section="Section One"/>    <command id="2" label="exit"  description=" logoff The HPUX System." section="Section One"/>    <command id="3" label="id"  description=" Display your user and group identifications." section="Section One"/>    <command id="4" label="who"  description=" Identify other users logged on to the system." section="Section One"/>    <command id="5" label="date"  description=" Display system date and time." section="Section One"/>    <command id="6" label="passwd"  description=" Assign a password to your user account." section="Section One"/>    <command id="7" label="echo"  description=" Display simple messages to your screen." section="Section One"/>    <command id="8" label="banner"  description=" Coding & Unit Testing." section="Section One"/>    <command id="9" label="clear"  description=" Clears terminal screen." section="Section One"/>         <command id="10" label="pwd"  description=" Displays the directory name of your current location in the hierarchy." section="Section Two"/>    <command id="11" label="ls"  description=" Sees what files and directories are under the current directory." section="Section Two"/>    <command id="12" label="cd"  description=" Changes your location in the hierarchy to another directory." section="Section Two"/>    <command id="13" label="find"  description=" Finds files." section="Section Two"/>    <command id="14" label="mkdir"  description=" Creates a directory." section="Section Two"/>    <command id="15" label="rmdir"  description=" Removes a directory." section="Section Two"/>    <command id="16" label="ls"  description=" Look at the characteristics of a file." section="Section Two"/>    <command id="17" label="cat"  description=" Look at the contents of a file." section="Section Two"/>    <command id="18" label="more"  description=" Look at the contents of a file." section="Section Two"/>    <command id="19" label="cp"  description=" Make a copy of a file" section="Section Two"/>    <command id="20" label="mv"  description=" Change the name of a file or directory." section="Section Two"/>    <command id="21" label="mv"  description=" Move a file to another directory." section="Section Two"/>    <command id="22" label="ln"  description=" Create another name for a file." section="Section Two"/>    <command id="23" label="rm"  description=" Remove a file." section="Section Two"/>    <command id="24" label="ls(ll, ls l)"  description=" Determine what access is granted on a file chmod Change access." section="Section Two"/>    <command id="25" label="umask"  description=" Change default file access." section="Section Two"/>    <command id="26" label="touch"  description=" Update timestamp on file." section="Section Two"/>    <command id="27" label="chown"  description=" Change the owner of a file." section="Section Two"/>    <command id="28" label="chgrp"  description=" Change the group of a file." section="Section Two"/>    <command id="29" label="su"  description=" Switch your user identifier." section="Section Two"/>    <command id="30" label="newgrp"  description=" Switch your group identifier." section="Section Two"/>      <command id="31" label="ps [-efl]"  description=" Report process status." section="Section Three"/>    <command id="32" label="Ctrl+Z"  description=" Putting jobs in Background/Foreground." section="Section Three"/>    <command id="33" label="nohup"  description=" Makes a command immune to hangup." section="Section Three"/>    <command id="34" label="nice[-N]"  description=" Runs aprocess at alower priority N is a number between 1 and 19." section="Section Three"/>    <command id="35" label="kill[-s signal_name]PID [PID...]"  description=" sends a signal to specified processes." section="Section Three"/></root> 



XML code
这是TitleWindows组建<?xml version="1.0" encoding="utf-8"?><mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="492" height="364" title="Command Reference" showCloseButton="true" close="PopUpManager.removePopUp(this);" color="#F1F8F9">    <mx:Script>         <!--[CDATA[              private function init():void              {                  var url:URLRequest = new URLRequest("command-info.xml");                  var loader:URLLoader = new URLLoader();                  loader.addEventListener(Event.COMPLETE,onComplete);                  loader.load(url);              }              private function onComplete(event:Event):void{                  var result:URLLoader = URLLoader(event.target);                  datas = XML(result.data);              }                                   ]]-->     </mx:Script>  <mx:Script>         <![CDATA[                      import mx.collections.ICollectionView;             import mx.events.ListEvent;                            /*              * Point area through the contents of the drop-down menu start              */             private function tree_itemClick(evt:ListEvent):void {                                   //Define the point add Tree Event use come true contents of the drop-down menu start                 var item:Object = Tree(evt.currentTarget).selectedItem;                                  //According the condition judge the point content                 if (treeXML.dataDescriptor.isBranch(item)) {                                          treeXML.expandItem(item, !treeXML.isItemOpen(item), true);                 }              }                         /*              * Request the node of number              */             private function tree_labelFunc(item:XML):String {                                  var children:ICollectionView;                                  var suffix:String = "";                                  if (treeXML.dataDescriptor.isBranch(item)) {                                          children = treeXML.dataDescriptor.getChildren(item);                     suffix = " (" + children.length + ")";                 }                 return item[treeXML.labelField] + suffix;             }         ]]>     </mx:Script>        <mx:Script>        <![CDATA[                    /*             * Default show all node of contents             */            private function initApp():void {               for each(var item:XML in this.treeXML.dataProvider)                   this.treeXML.expandChildrenOf(item,true);     }        ]]>    </mx:Script>        <mx:Script>        <![CDATA[        import mx.managers.PopUpManager;            [Bindable]            public var selectedNode:XML;            // Event handler for the Tree control change event.            public function treeChanged(event:Event):void {                selectedNode=Tree(event.target).selectedItem as XML;            }        [Bindable]        [Embed("images/skin/titlewindow/titleWindowBg.png")]        public var VBoxBg:Class;        [Bindable]        [Embed("images/tree/icon/point.png")]        public var point:Class;        ]]>            </mx:Script>           <mx:XML id="dynamicTreeXML" source="assets/configfiles/commandTwo-info.xml"/>    <mx:VBox x="30" y="10" height="284" width="432">        <mx:Tile width="429" height="23">            <mx:Label text="A  B  C  D  E  F  G  H  I  Z  K  L  M  N  O  P  Q  R  S  T  U  X  Y  Z" width="418" height="23" fontWeight="bold" fontSize="13" fontFamily="Georgia" color="#3291C3"/>        </mx:Tile>        <mx:Label text="Select Command" width="104" height="23" fontSize="12" color="#3291C3" fontWeight="bold"/>        <mx:HBox width="423" height="226">            <mx:Tree id="treeXML" change="treeChanged(event)" creationComplete="initApp()" dataProvider="{dynamicTreeXML}" labelField="@label" labelFunction="tree_labelFunc" itemClick="tree_itemClick(event)" rowCount="6" showRoot="false" width="200" height="224" backgroundColor="#E2F5FA" color="#3291C3"/>            <mx:TextArea width="210" height="223" color="#3291C3" text="{selectedNode.@description}" />        </mx:HBox>    </mx:VBox>    </mx:TitleWindow> 



我的问题是通过怎样的方式在点击 A B C D E F。。。。。。也就是定义的首字母时,在左边的Tree中显示XML定义的信息里相关字母开头的Command ?
A B C D 怎样定义才能是可点击的,本人新手很多都不懂,希望大家多多提意见 或者是用其他的方法实现这样的功能,多多指点。

[解决办法]
如(思路没做测试):
XML code
[Bindable]private var xmlValue:XMLListCollection;private function queryXML(par:String):void{  xmlValue = dynamicTreeXML.command.(contains(@label,par))}  <mx:Tree id="treeXML" dataProvider="{xmlValue }" labelField="@label" />.. 

读书人网 >flex

热点推荐