在我的应用程序中,我正在使用Scroller http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/Scroller.html成分。我似乎无法弄清楚应该在哪个事件上设置侦听器才能知道内容何时滚动。我试过Event.CHANGE
on Scroller.verticalScrollBar
属性,但显然当用户使用鼠标滚轮或箭头键滚动时该事件不会触发。
您可以在 Scroller 的视口上监听 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)