[英]as3 mouse wheel reverse
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);
All you need to do is invert the delta value (or the direction in which you scroll): 您需要做的就是反转delta值(或滚动的方向):
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. 请注意,我所做的只是在event.delta值前加一个减号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.