gpt4 book ai didi

apache-flex - Flex 4 滚轮

转载 作者:行者123 更新时间:2023-12-03 16:27:00 28 4
gpt4 key购买 nike

在我的应用程序中,我使用了 Scroller零件。我似乎无法弄清楚我应该在哪个事件上设置一个监听器以便知道何时滚动内容。我试过Event.CHANGEScroller.verticalScrollBar属性,但显然当用户使用鼠标滚轮或箭头键滚动时该事件不会触发。

最佳答案

您可以在 Scroller 的视口(viewport)上监听 propertyChange 事件。这是一个演示如何完成此操作的应用程序:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.events.PropertyChangeEvent;

private function init():void {
// spark Scroller: listen on the viewport property
myScroller.viewport.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, handle);
}

/**
* Handle scroll position changes
*/
private function handle(e:PropertyChangeEvent):void {
if (e.source == e.target && e.property == "verticalScrollPosition")
trace(e.property, "changed to", e.newValue);
if (e.source == e.target && e.property == "horizontalScrollPosition")
trace(e.property, "changed to", e.newValue);
}
]]>
</fx:Script>

<s:Scroller id="myScroller" width="100" height="100">
<s:Group>
<s:Button label="large content" width="300" height="300"/>
</s:Group>
</s:Scroller>

</s:Application>

关于apache-flex - Flex 4 滚轮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4390725/

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