AS3 MouseEvent Wheel Question
Copy link to clipboard
Copied
I have put a 3072 height Movie clip on the stage that I would like to scroll up and down on. Searching help I have came up with the code below:
import flash.events.MouseEvent;
function mouseWheel (event : MouseEvent):void {
if ((event.delta < 0 && box_mc.y > 0 )||
(event.delta > 0 && box_mc.y < stage.stageHeight - box_mc.height)){
box_mc.y = box_mc.y + (event.delta * 2);
}
}
stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheel);
I will scroll down but not up. I was seeing about reversing this function but am lost on how to do so. How would I got about reversing this function so that I may mouse wheel up and mouse wheel down?
Where would I look in help to find if I was to scroll and have it ease into the mouse wheel event rather than just slowing moving without ease?
Thank you in advanced for any help and advice.
Copy link to clipboard
Copied
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel);
function mouseWheel(event:MouseEvent):void
{
if (box_mc.y >= 0 && box_mc.y <= stage.stageHeight)
{
box_mc.y -= event.delta;
}
else
{
if (box_mc.y < 0)
{
box_mc.y = 0;
}
else if (box_mc.y > stage.stageHeight)
{
box_mc.y = stage.stageHeight;
}
}
}

