5 Replies Latest reply on May 2, 2017 11:21 AM by kglad

    Problem with GESTURE_SWIPE on EventListener

    angelom77716812

      I have two different elements that need a swipe gesture on the same scene.

      I'e been working with

       

      Multitouch.inputMode = MultitouchInputMode.GESTURE;

       

       

      square1.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);

      function onSwipe(e: TransformGestureEvent): void {

        if (e.offsetX == 1) {

        //User swiped towards right

        square1.x += 100;

        }

        if (e.offsetX == -1) {

        //User swiped towards left

        square1.x -= 100;

        }

        if (e.offsetY == 1) {

        //User swiped towards bottom

        square1.y += 100;

        }

        if (e.offsetY == -1) {

        //User swiped towards top

        square1.y -= 100;

        }

      }

       

      square2.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe2);

      function onSwipe2(e: TransformGestureEvent): void {

        if (e.offsetX == 1) {

        //User swiped towards right

        square2.x += 100;

        }

        if (e.offsetX == -1) {

        //User swiped towards left

        square2.x -= 100;

        }

        if (e.offsetY == 1) {

        //User swiped towards bottom

        square2.y += 100;

        }

        if (e.offsetY == -1) {

        //User swiped towards top

        square2.y -= 100;

        }

      }

       

      square1 and square2 being my 2 elements.

      I can swipe one and then the other one won't work. What could i do so the gesture doesn't get stuck on just one of the events?