Skip to main content
oliversen
Inspiring
June 3, 2018
Question

Scrollfunction - "pushing" button when releasing mouse from scrolling

  • June 3, 2018
  • 1 reply
  • 276 views

I have a scrollfunction on a container(MovieClip). The container has a instance of several buttons(other movieclips). When I scroll the container and release the mouse I automatically push the button where the mouse release the scroll. If that was understandable.

I scroll, when I release the scroll. One of the buttons is pushed.

I have tried adding a if sentence with the "offsetY" like this:

//if(offsetY>30 || offsetY<-30)

I have tried adding a timer in the mouseUpHandler, without success.

container.addEventListener(MouseEvent.CLICK, onMouse); // This is the code that is triggered.

var maxY: Number = 0;

var minY: Number = Math.min(0, stage.stageHeight - container.height - mcTopic.height - blaatt.height - controlButtons.height - mcNowPlaying.height);

var _startY: Number;

var _startMouseY: Number;

addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

function mouseDownHandler(event: MouseEvent): void {

_startY = container.y;

_startMouseY = mouseY;

stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler, false, 0, true);

stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler, false, 0, true);

}

function stage_mouseMoveHandler(event: MouseEvent): void {

var offsetY: Number = mouseY - _startMouseY;

container.y = Math.max(Math.min(maxY, _startY + offsetY), minY);

container1.y = Math.max(Math.min(maxY, _startY + offsetY), minY);

}

function stage_mouseUpHandler(event: MouseEvent): void {

stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler);

stage.removeEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler);

}

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
June 4, 2018

You could try disabling the other buttons while the scroll is in use, up until after it is released.  You could either remove the event listeners for the other buttons or put in a conditional with a variable that gets set/checked and disallows/enables the code within the event handlers for the other buttons. It might even be as simple as setting the mouseChildren property of the container to false while the scroll is active.