gpt4 book ai didi

apache-flex - Adobe Flex 以编程方式重新定位滚动条 slider

转载 作者:行者123 更新时间:2023-12-04 07:10:21 24 4
gpt4 key购买 nike

我需要以编程方式重新定位滚动条上的 slider (不移动滚动条,只移动 slider ;即将其重置为顶部或左侧等)。有人想出这个吗?

最佳答案

我本来要提到程序化蒙皮,但再想一想,听起来你想要做的只是设置组件的滚动位置。是对的吗?如果是这样,这取决于您使用的是哪种控件,以及您想要执行哪种滚动(例如,到列表中的项目,或者只是到水平或垂直位置):

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
<![CDATA[

private function scrollToIndex():void
{
ls.scrollToIndex(15);
}

private function scrollToPoint():void
{
cv.verticalScrollPosition += 20;
}

]]>
</mx:Script>

<mx:VBox width="300">
<mx:List id="ls" width="100%" rowCount="5">
<mx:dataProvider>
<mx:Array>
<mx:String>Item 1</mx:String>
<mx:String>Item 2</mx:String>
<mx:String>Item 3</mx:String>
<mx:String>Item 4</mx:String>
<mx:String>Item 5</mx:String>
<mx:String>Item 6</mx:String>
<mx:String>Item 7</mx:String>
<mx:String>Item 8</mx:String>
<mx:String>Item 9</mx:String>
<mx:String>Item 10</mx:String>
<mx:String>Item 11</mx:String>
<mx:String>Item 12</mx:String>
<mx:String>Item 13</mx:String>
<mx:String>Item 14</mx:String>
<mx:String>Item 15</mx:String>
<mx:String>Item 16</mx:String>
<mx:String>Item 17</mx:String>
<mx:String>Item 18</mx:String>
<mx:String>Item 19</mx:String>
<mx:String>Item 20</mx:String>
</mx:Array>
</mx:dataProvider>
</mx:List>
<mx:Button label="Scroll" click="scrollToIndex()" />
<mx:Canvas id="cv" width="100%" height="200">
<mx:TextArea width="100%" height="600" verticalScrollPolicy="off">
<mx:text>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</mx:text>
</mx:TextArea>
</mx:Canvas>
<mx:Button label="Scroll" click="scrollToPoint()" />
</mx:VBox>

</mx:Application>

verticalScrollPosition 和 Horizo​​ntalScrollPosition 属性(可用于 Container 类的所有实现)和 scrollToIndex 方法(用于列表)可能是您正在寻找的。这个例子说明了两者。希望能帮助到你!

关于apache-flex - Adobe Flex 以编程方式重新定位滚动条 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/467497/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com