Flex 4 滚轮 [英] Flex 4 Scroller
本文介绍了Flex 4 滚轮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我使用了 滚动器 组件.我似乎无法弄清楚应该在哪个事件上设置侦听器才能知道何时滚动内容.我在 Scroller.verticalScrollBar
属性上尝试了 Event.CHANGE
但显然当用户使用鼠标滚轮或箭头键滚动时该事件不会触发.
Within my application I'm using a Scroller component. I can't seem to figure out which event I should set up a listener on in order to know when content is scrolled. I tried Event.CHANGE
on Scroller.verticalScrollBar
property but apparently that event doesn't fire when the user scrolls with a mouse wheel or arrow keys.
推荐答案
您可以在 Scroller 的视口上监听 propertyChange 事件.下面是一个演示如何完成此操作的应用程序:
You can listen for the propertyChange event on the viewport of the Scroller. Here is an application that demonstrates how this might be done:
<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>
这篇关于Flex 4 滚轮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文