Flex,一个mx:Spark应用程序中的树,当我折叠一个树节点时,滚动条将移动到顶部,测试代码如下:
<?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:Script>
<![CDATA[
import mx.collections.XMLListCollection;
[Bindable]
private var treeData:XML =
<node label='root'>
<node label="Monkeys">
<node label="South America">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Africa" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Asia" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
</node>
<node label="Sharks">
<node label="South America" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Africa" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Asia" >
<node label="Coastal"/>
<node label="Inland"/>
</node>
</node>
</node>;
private function init():void{
myTree.expandChildrenOf(myTree.firstVisibleItem, true);
}
]]>
</fx:Script>
<mx:Tree id="myTree"
y="50"
width="221"
height="207"
horizontalCenter="0"
dataProvider="{treeData.node}"
labelField="@label"/>
</s:Application>
<?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:Script>
<![CDATA[
import mx.collections.XMLListCollection;
[Bindable]
private var treeData:XML =
<node label='root'>
<node label="Monkeys">
<node label="South America">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Africa" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Asia" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
</node>
<node label="Sharks">
<node label="South America" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Africa" isBranch="true">
<node label="Coastal"/>
<node label="Inland"/>
</node>
<node label="Asia" >
<node label="Coastal"/>
<node label="Inland"/>
</node>
</node>
</node>;
private function init():void{
myTree.expandChildrenOf(myTree.firstVisibleItem, true);
}
]]>
</fx:Script>
<mx:Tree id="myTree"
y="50"
width="221"
height="207"
horizontalCenter="0"
dataProvider="{treeData.node}"
labelField="@label"/>
</s:Application>