Skip to main content
Participant
July 20, 2011
Answered

Pan Gesture doesn't get triggered

  • July 20, 2011
  • 3 replies
  • 1177 views

Can Some one explain me why my "TransformGestureEvent.GESTURE_PAN" doesn't get triggered?

All the other gesture events are triggered.

I find it a bit confusing

Oh yeah, i am developing for every platform but testing on a google phone nexus S

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.TransformGestureEvent;
    import flash.geom.Point;
    import flash.ui.Multitouch;
    import flash.ui.MultitouchInputMode;
   
    public class PanTest extends Sprite
    {
        private var _target:Sprite;
       
        public function PanTest()
        {
            // support autoOrients
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
           
            Multitouch.inputMode = MultitouchInputMode.GESTURE;
           
            _target = new Sprite();
            _target.graphics.beginFill(0x99ff00);
            _target.graphics.drawRect(-200, -200, 400, 400);
            _target.transform.matrix.tx = 200;
            _target.transform.matrix.ty = 200;
            _target.x = stage.stageWidth / 2;
            _target.y = stage.stageHeight / 2;
            addChild(_target);
           
            if (Multitouch.supportsGestureEvents)
            {
                for each (var item:String in Multitouch.supportedGestures)
                {
                    trace(item)
                   
                    switch (item)
                    {
                        case TransformGestureEvent.GESTURE_PAN:
                        {
                            _target.addEventListener(TransformGestureEvent.GESTURE_PAN, _gestureHandler);
                            break;
                        }
                        case TransformGestureEvent.GESTURE_ROTATE:
                        {
                            _target.addEventListener(TransformGestureEvent.GESTURE_ROTATE, _gestureHandler);
                            break;
                        }
                        case TransformGestureEvent.GESTURE_SWIPE:
                        {
                            _target.addEventListener(TransformGestureEvent.GESTURE_SWIPE, _gestureHandler);
                            break;
                        }
                        case TransformGestureEvent.GESTURE_ZOOM:
                        {
                            _target.addEventListener(TransformGestureEvent.GESTURE_ZOOM, _gestureHandler);
                            break;
                        }
                    }
                }
            }
        }
       
        protected function _gestureHandler(e:TransformGestureEvent):void
        {
            trace(e.type);
           
            switch (e.type)
            {
                case TransformGestureEvent.GESTURE_PAN:
                {
                    var prevPoint:Point = new Point(_target.x, _target.y);
                    _target.x += e.offsetX * 3;
                    _target.y += e.offsetY * 3;
                    break;
                }
                case TransformGestureEvent.GESTURE_ROTATE:
                {
                    _target.rotation += e.rotation;
                    break;
                }
                case TransformGestureEvent.GESTURE_SWIPE:
                {
                   
                    break;
                }
                case TransformGestureEvent.GESTURE_ZOOM:
                {
                    _target.scaleX *= e.scaleX;
                    _target.scaleY *= e.scaleY;
                    break;
                }
            }
        }
    }
}

This topic has been closed for replies.
Correct answer Pahup

Johan,

I assume that you've verified it using trace statements in the PAN switch block.

How are your performing PAN gesture on the screen, just wanted to remind you that it's a two finger gesture.

You need to use two fingers to pan the sprite.

-Pahup

3 replies

Participant
July 21, 2011

Dang Mark, your totally right...

It still does not compute with me that the pan event trigger is done by two fingers...

Still thanks all for helping me out!

Pahup
Adobe Employee
Adobe Employee
July 22, 2011

Sorry, couldn't get you, Did that work?

-Pahup

July 20, 2011

Doesn't look like it in your script but if you have a touch event somewhere on the page they will cancel each other out, so you cant have a swipe and a touch event running parallel to each other.

Pahup
Adobe Employee
PahupCorrect answer
Adobe Employee
July 21, 2011

Johan,

I assume that you've verified it using trace statements in the PAN switch block.

How are your performing PAN gesture on the screen, just wanted to remind you that it's a two finger gesture.

You need to use two fingers to pan the sprite.

-Pahup

markc888
Inspiring
July 20, 2011

It might be to do with the pan gesture working with phases

if (e.phase==GesturePhase.BEGIN) {

   // panel_mc.txt.text = "Begin";

    e.target.scaleX = 1.1;

    e.target.scaleY = 1.1;

}

if (evt.phase==GesturePhase.UPDATE) {

   // panel_mc.txt.text = "Update";

    e.target.alpha = 0.5;

}

if (evt.phase==GesturePhase.END) {

   // panel_mc.txt.text = "End";

    e.target.scaleX = 1;

    e.target.scaleY = 1;

}

Participant
July 20, 2011

i read about the eventphase handling in the documentation but my problem lies in not at the eventphases handling.

The event itself is not being dispatched, thus i dont recieve the pan gesture trigger.

Or is my event listener handling wrong?