Skip to main content
Known Participant
January 21, 2013
Question

AIR swipe function doesn't work

  • January 21, 2013
  • 1 reply
  • 5983 views

I'm using Swipe function from codesnippet, but this code doesn't work for some reason, it doesn't report an error, but doesn't work. I've placed code on Background MC as suggested.

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler_2);

function fl_SwipeHandler_2(event:TransformGestureEvent):void

{

    switch(event.offsetX)

    {

        // swiped right

        case 1:

        {

            MyMC.gotoAndStop(105);

            break;

        }

        // swiped left

        case -1:

        {

           

            MyMC.gotoAndStop(100);

            break;

        }

    }

}

This topic has been closed for replies.

1 reply

Inspiring
January 21, 2013

Put this line in fornt of your switch

trace(event.offsetX);

What do you get?

Another point:

Every switch condition needs a closing default statement.

case 1:

case 2:

default: break;

mari8899Author
Known Participant
January 21, 2013

That doesn't work what you said, produced more errors.

I used default codesnippet which should work, but it doesn't. Also please send full code so there are no mistakes, thanks.

Inspiring
January 21, 2013

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler_2);

function fl_SwipeHandler_2(event:TransformGestureEvent):void

{

    trace(event.offsetX);

    switch (event.offsetX)

    {

            // swiped right

        case 1 :

            MyMC.gotoAndStop(105);

            break;

            // swiped left

        case -1 :

            MyMC.gotoAndStop(100);

            break;

        default :

            break;

    }

}