5 Replies Latest reply on May 14, 2013 9:02 AM by TheBionicGroup

    Swipe to trigger an action

    grouchou Level 1

      Hi everyone,

       

      after having studied the question reading different post on the subject I tried to trigger an action by swipping with one finger.

      It almost work but there is a little problem.

       

      Here is what I've done :

      On the stage I put this code on the touchstart event :

       

      e.preventDefault();

      var xStart = e.originalEvent.touches[0].pageX;

      sym.setVariable('xStart', xStart);

       

      and on touchend event I put this :

       

      e.preventDefault();

      xStart = sym.getVariable('xStart');

      var xEnd = e.originalEvent.touches[0].pageX;

      if (xEnd > xStart)

      {

          sym.play("play1");

      }

      else if (xEnd < xStart)

      {

          sym.play("play2");

      }

       

      the problem i that for some reason it only works with two fingers and not with only one. I can't understand why...

       

      Another question :

      The second step is to allow the swipe to trigger the action only it the swipe has been made in a precise rectangle.

      I know I could use the same code and test x,y of the stage to know if the swipe was is the right place but I was wondering if I could just define the rectangle with opacity at 0 and then put touchend and touchstart events on this rectangle. Would it work ?

       

       

      If someone can help, it would be great !

        • 1. Re: Swipe to trigger an action
          TheBionicGroup

          Hi Grouchou,

           

          I am having similar problems to you regarding the one/two finger swipes. Did you manage to find a solution? Did you also get it working in a set area?

           

          Thanks

          • 2. Re: Swipe to trigger an action
            grouchou Level 1

            Hi Hélène,

             

            I have the solution but I'm not home yet to give you the code.

            Once at home Sunday evening I give you the whole code and details.

             

            Have a nice day,

             

            Mathieu.

             

             

             

            Le 10 mai 2013 à 13:52, HelenH <forums_noreply@adobe.com> a écrit :

             

             

            Re: Swipe to trigger an action

            created by HelenH in Edge Animate - View the full discussion

            Hi Grouchou,

             

             

             

            I am having similar problems to you regarding the one/two finger swipes. Did you manage to find a solution? Did you also get it working in a set area?

             

             

             

            Thanks

             

            Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5308548#5308548

            Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5308548#5308548

            To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5308548#5308548. In the Actions box on the right, click the Stop Email Notifications link.

            Start a new discussion in Edge Animate by email or at Adobe Community

            For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

             

            • 4. Re: Swipe to trigger an action
              grouchou Level 1

              Hi Helen,

               

              Here is how I have doen :

               

              in the stage code I have 3 pieces of code for 3 events : touchend, touch start en compositionready.

               

              In the touchstart copy paste this code :

               

              e.preventDefault();

               

              if ( e.pageX == undefined ) {

               

                   var touch = e.originalEvent.touches || e.originalEvent.changedTouches ;

               

                   this.swipeStartY = touch.pageY;

                   this.swipeStartX = touch.pageX;

              }

               

              In the touchend panel copy past this code :

               

              e.preventDefault();

               

              if ( e.pageX == undefined ) {

               

                   var touch = e.originalEvent.touches || e.originalEvent.changedTouches ;

                   this.swipeEndY = touch.pageY;

                   this.onSwipe();

              }

               

               

              In the compositionready panel copy paste this code :

               

              // insert code for compositionReady event here

               

              // GLOBAL VARS

              • 5. Re: Swipe to trigger an action
                TheBionicGroup Level 1

                Thanks for the code.

                 

                What do I put where it says "Re: Swipe to trigger an action"? Also do in need to define the variable touch in the compositionready panel?

                 

                Many thanks

                Helen