flex4中的Scroller,监听滚动事件

Scroller有水平滚动条horizontalScrollBar和竖起滚动条verticalScrollBar,监听change事件即可。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:mx="library://ns.adobe.com/flex/mx"
           xmlns:s="library://ns.adobe.com/flex/spark" 
               creationComplete="init(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
private function init(event:FlexEvent):void
{
trace("init");
scroller.verticalScrollBar.addEventListener(Event.CHANGE, onChange);
}
private var count:int = 0;
private function onChange(event:Event):void
{
trace("change" + count++);
}
]]>
</fx:Script>
<s:Scroller id="scroller" width="200" height="400">
<s:Group id="viewport" width="100%" height="400">
<s:Rect width="100%" height="3000">
<s:fill>
<s:LinearGradient rotation="90">
<s:entries>
<s:GradientEntry color="0x222222" ratio="0"/>
<s:GradientEntry color="0xDDDDDD" ratio="1"/>
</s:entries>
</s:LinearGradient>
</s:fill>
</s:Rect>
</s:Group>
</s:Scroller>
</s:Application>

转载:http://bbs.9ria.com/blog-185280-14037.html

你可能感兴趣的:(flex4中的Scroller,监听滚动事件)