• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Make a list scrollable without the scrollbar

Participant ,
Apr 22, 2018 Apr 22, 2018

Copy link to clipboard

Copied

I have a list called "list".


I want the scrollbar to be there, but I do want to be able to scroll the list dragging it up and down wherever I touch.

The code attached below I have used to scroll a Movieclip.

var maxY: Number = 0;

var minY: Number = Math.min(0, stage.stageHeight - list.height);

var _startY: Number;

var _startMouseY: Number;

addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

function mouseDownHandler(event: MouseEvent): void {

_startY = list.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;

list.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);

}

TOPICS
ActionScript

Views

191

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation