11 Replies Latest reply on Jun 5, 2013 12:56 PM by sinious

    using the press and Tap Gesture event - Adobe AIR

    Mordred58 Level 1

      I'm having trouble getting a tap gesture to work. I've attached the code that I've been attempting.

       

      function driverManualHandler(event:GestureEvent):void

      {

                if (event.phase == GesturePhase.ALL)

                {

                          milApp.driverManual_mc.visible = true;

                          milApp.driverManual_btn.visible = false;

                          milApp.cheatSheet_mc.visible = false;

                          milApp.referenceManual_btn.visible = false;

                          milApp.cheatSheet_btn.visible = false;

                          milApp.closeButton_btn.visible = true;

                }

      }

      milApp.driverManual_btn.addEventListener(PressAndTapGestureEvent.GESTURE_PRESS_AND_TAP, driverManualHandler);

        • 1. Re: using the press and Tap Gesture event - Adobe AIR
          sinious Most Valuable Participant

          Make sure you have the PressAndTapGestureEvent imported and you've set it up for multi-touch ala:

          Multitouch.inputMode = MultitouchInputMode.GESTURE;

           

          Being you're doing this for all event phases you know this will fire off multiple times for a single touch right? You may just want to assign it to the lifting of the fingler.

           

          e.g.

          function driverManualHandler(event:GestureEvent):void

          {

                    if (event.phase == GesturePhase.END)

                    {

                              milApp.driverManual_mc.visible = true;

                              milApp.driverManual_btn.visible = false;

                              milApp.cheatSheet_mc.visible = false;

                              milApp.referenceManual_btn.visible = false;

                              milApp.cheatSheet_btn.visible = false;

                              milApp.closeButton_btn.visible = true;

           

              // try a trace in here, make sure the function is firing off

              trace('GesturePhase.END invoked');

                    }

          }

          • 2. Re: using the press and Tap Gesture event - Adobe AIR
            Mordred58 Level 1

            I do have the multitouch event imported. however, that did not seem to help.  i had used the touch event before (which worked) but I had to go away from it, since I need to use the Swipe Gesture in other parts of the app.

            • 3. Re: using the press and Tap Gesture event - Adobe AIR
              sinious Most Valuable Participant

              A tap can simply be a mouse event, you don't really need a tap. If you're interested in the speed of the tap a simple timer could help you determine the tap speed. I realize the gesture should just work but this is pretty basic Flash territory.

               

              Which device is giving you issues with it and have you tested it to see what gestures it supports?

              • 4. Re: using the press and Tap Gesture event - Adobe AIR
                Mordred58 Level 1

                I'm getting more results from the flash emulator than i am from the actual device (Samsung Galaxy Tab 2 10.1). 

                • 5. Re: using the press and Tap Gesture event - Adobe AIR
                  sinious Most Valuable Participant

                  Does it say it supports your gesture?

                  • 6. Re: using the press and Tap Gesture event - Adobe AIR
                    Mordred58 Level 1

                    i've seen in other places where the gestures are supported. 

                    • 7. Re: using the press and Tap Gesture event - Adobe AIR
                      sinious Most Valuable Participant

                      Flash emulators job is to do as much as possible to let you test so it will emulate the gestures for testing. You hold control or a key combination to invoke them for testing.

                       

                      I've found tablets and phones often support all gestures but computers with touchscreens often support very few. Although you're saying Galaxy Tab 2 doesn't support it which is pretty surprising. The question still stands however. Does Galaxy Tab 2 report it supports the gesture you're trying to use? Consult what I linked above to check the supportedGestures method.

                       

                      And again, tap is very basic. Often gestures like swipe aren't supported at all on PCs because it's very easy to simulate with basic mouse events. If you MOUSE_DOWN on an object and over a short time move horizontally X (threshhold) number of pixels and then MOUSE_UP, that's a swipe. It might be worth your time to simply use mouse events instead of tap and put this issue in the rear view mirror.

                      • 8. Re: using the press and Tap Gesture event - Adobe AIR
                        Mordred58 Level 1

                        The Samsung does support the touch and swipe gesture.  if i attempt to use mouse events, will that be recognized by the tablet? 

                         

                        I understand that the tap gesture is fairly basic,which is why it's frustrating that it's not working.  i can provide my entire code if you want to take a look.

                        • 9. Re: using the press and Tap Gesture event - Adobe AIR
                          sinious Most Valuable Participant

                          It's just PCs, trackpads and Mac magic mice that for whatever reason lack swipe often. All my mobile devices support it.

                           

                          I would just use normal mouse events if it isn't a huge rework for you. Gesture support itself is known to slow down older devices due to the speed at which they run sensing code. I try not to use them at all unless I'm in a rush. I just use mouse events that yes will work just fine on devices.

                          • 10. Re: using the press and Tap Gesture event - Adobe AIR
                            Mordred58 Level 1

                            Thank you for helping me out wiht this...so...when using mouse events instead of touch events and swipe events, you can use MOUSE_DOWN to be the same as the person pressing their finger against the device, and MOUSE_UP for releasing? 

                            • 11. Re: using the press and Tap Gesture event - Adobe AIR
                              sinious Most Valuable Participant

                              Yep. Open a new Flash or Flash Builder project, just paste in this quick class and run it on your device in USB debug mode and watch it trace:

                               

                              package

                              {

                                        import flash.display.Sprite;

                                        import flash.display.Stage;

                                        import flash.display.StageAlign;

                                        import flash.display.StageScaleMode;

                                        import flash.events.Event;

                                        import flash.events.MouseEvent;

                               

                                        public class CheckMouseEvents extends Sprite

                                        {

                                                  public function CheckMouseEvents()

                                                  {

                                                            super();

                                                            stage.scaleMode = StageScaleMode.NO_SCALE;

                                                            stage.align = StageAlign.TOP_LEFT;

                                                            addEventListener(Event.ACTIVATE, _onActivate);

                                                  }

                               

                                                  protected function _onActivate(event:Event):void

                                                  {

                                                            removeEventListener(Event.ACTIVATE, _onActivate);

                                                            trace("Listening...");

                               

                                                            var s:Sprite = new Sprite();

                                                            addChild(s);

                                                            s.graphics.beginFill(0xFF0000,1);

                                                            s.graphics.drawRect(0,0,200,200);

                                                            s.graphics.endFill();

                                                            s.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void{trace("Mouse Down!");});

                                                            s.addEventListener(MouseEvent.MOUSE_UP, function(e:MouseEvent):void{trace("Mouse Up!");});

                                                            s.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void{trace("Mouse Click!");});

                               

                                                  }

                                        }

                              }

                               

                              My trace as I touch it:

                               

                              Listening...

                              [SWF] CheckMouseEvents.swf - 1,897 bytes after decompression

                              Mouse Down!

                              Mouse Up!

                              Mouse Click!

                              Mouse Down!

                              Mouse Up!

                              Mouse Click!