Features  »  Supported Gestures  »  Scroll (Horizontal) Gesture

Scroll (Horizontal)

The ‘horizontal scroll’ event tracks the horizontal magnitude of change and returns a numerical value that can be passed to an element to change its horizontal position.

Using the Horizontal Scroll Gesture

The ‘horizontal scroll’ event is typically used to scroll an element right and left or to create horizontal scrollbars.

Mechanics and Code Samples

To register a ‘horizontal scroll’, touch down two fingers on the touch screen surface at the same time, horizontally positioned to one another, and then drag them across the screen surface horizontally.

1
txtArea.addEventListener(GestureEvent.GESTURE_SCROLL, txtArea_scrollHandler);
1
2
3
4
5
6
7
8
private function txtArea_scrollHandler(event:GestureEvent):void
{
  var value:Number = (txtArea.HorizontalScrollPosition + event.scrollX);

  txtArea.verticalScrollPosition =
    value > txtArea.maxHorizontalScrollPosition ? txtArea.maxHorizontalScrollPosition :
    value < 0 ? 0 : value;
}

Parameters

All touch and gesture events have a localX and localY (relative) position as well as a stageX and stageY (absolute) position.

Related Gestures

Scroll (Vertical)