代码:
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- private function openAllNodes():void {
- tree.openItems = dp..node;
- }
- private function closeAllNodes():void {
- tree.openItems = [];
- }
- ]]>
- </mx:Script>
- <mx:XML id="dp">
- <root>
- <node label="Parent 1">
- <node label="Child 1" />
- <node label="Child 2">
- <node label="Grandchild 1" />
- <node label="Grandchild 2" />
- </node>
- <node label="Child 3" />
- <node label="Child 4" />
- </node>
- </root>
- </mx:XML>
- <mx:ApplicationControlBar dock="true">
- <mx:Button label="Open all nodes" click="openAllNodes();" />
- <mx:Button label="Close all nodes" click="closeAllNodes();" />
- </mx:ApplicationControlBar>
- <mx:Tree id="tree"
- dataProvider="{dp}"
- showRoot="false"
- labelField="@label"
- width="200" />
- </mx:Application>
- <!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/
- Minified using disk
- Page Caching using disk (enhanced) (request URI contains query)
- Database Caching using disk
- Object Caching 63/145 objects using disk
- Served from: blog.minidx.com @ 2012-08-06 07:42:29 -->
效果: