<triband>true</triband> <camera>false</camera> <video>false</video> <highlight1>Multimedia messaging</highlight1> <highlight2>Animated screensavers</highlight2> </product> <product productId="5"> <name>Nokia 3220</name> <description>The Nokia 3220 phone is a fresh new cut on some familiar ideas - animate your MMS messages with cute characters, see the music with lights that flash in time with your ringing tone, download wallpapers and screensavers with matching color schemes for the interface.</description> <price>159.99</price> <image>assets/pic/Nokia_3220.gif</image> <series>3000</series> <triband>false</triband> <camera>true</camera> <video>false</video> <highlight1>MIDI tones</highlight1> <highlight2>Cut-out covers</highlight2> </product> </catalog> </mx:XML> </mx:Application>
2.在 Tree 中查找节点。在对话框中输入要查找的节点的值。
<?xml version="1.0" encoding="utf-8"?> <!-- Searchable Tree control example. uses e4x expression to find a node with matching id attribute--> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()"> <mx:Script><![CDATA[ [Bindable] public var _xmlData:XML; public function initApp():void { _xmlData = <element eid="hello"> <element eid="world"> <element eid="123"/> <element eid="graham"/> <element eid="weldon"> <element eid="office"> <element eid="thing"/> <element eid="boat"/> <element eid="chair"/> </element> <element eid="person"/> </element> </element> </element> ; trace("test") }//initapp //starts at the given node, walks up the tree opening nodes as it goes private function expandParents(xmlNode:XML):void { while (xmlNode.parent() != null) { xmlNode = xmlNode.parent(); myTree.expandItem(xmlNode,true, false); } }//expandParents
//uses e4x to find a node, then calls expand parents to make it visible, //then selects it private function findNodeById(sId:String):void { var xmllistDescendants:XMLList = _xmlData.descendants().(@eid == sId); expandParents(xmllistDescendants[0]); myTree.selectedItem = xmllistDescendants[0]; }//findNodeById ]]></mx:Script> |