Wednesday 13 July 2011

The mouse wheel scroll with VGroup and Scroller is not smooth and it jumps abnormal points

adobe flex4.0 AS3.0


This is happening when you have photos in the VGroup, the Scroller jumps the photos each time in order to be viewed whole and not cut. This sometimes is not working well or we don’t want it.

What we have to do is to get the mousewheel event and calculate by our own the vertical scroll position.

1. implement the event like above:

protected function scroller1_mouseWheelHandler(event:MouseEvent):void{
  //calculate the new position 
  vgroup.verticalScrollPosition+=(event.delta*-20);            
  //stop the event’s bubbling
  event.stopPropagation();
}

2. add the event listener by your own! Because we want to get it before calculate the vertical scroll position. In event’s world… "we want to capture it", and this could be done only is we add the listener by our own, note the underlined true argument, so do:

scroller.addEventListener(MouseEvent.MOUSE_WHEEL,scroller1_mouseWheelHandler,true);

That's all

1 comment: