问题
Hey i built custom scroll box. When i scroll up on this box scrolling element is going down and when i scroll down - scrolling element is going up ;). I whant to reverse that mechanism. how can i do it ? Below my code for mouse
import flash.events.MouseEvent;
function handleMouseWheel(event:MouseEvent):void {
if ((event.delta > 0 && box_mc.y < 171) || (event.delta < 0 && box_mc.y > 135))
{
box_mc.y = box_mc.y + (event.delta * 3);
sb.thumb.y = sb.thumb.y + (event.delta * 13);
trace(box_mc.y);
trace(event.delta);
}
}
stage.addEventListener(MouseEvent.MOUSE_WHEEL, handleMouseWheel);
回答1:
All you need to do is invert the delta value (or the direction in which you scroll):
if ((event.delta > 0 && box_mc.y < 171) || (event.delta < 0 && box_mc.y > 135))
{
box_mc.y = box_mc.y + (-event.delta * 3);
sb.thumb.y = sb.thumb.y + (-event.delta * 13);
trace(box_mc.y);
trace(event.delta);
}
Notice all I have done is put a minus symbol in front of the event.delta value.
来源:https://stackoverflow.com/questions/14876389/as3-mouse-wheel-reverse