Swiping AppStudio Help


#1

I am working on a project where I need to swipe to the next form, but when I do, it goes to from Form3 to Form6. I need it to go in order from Form3 to Form4, Form5, Form6 and am not sure why it is skipping those forms. Here is the code for my Form3 swiping.

var swStartX, swStartY, swCurX, swCurY;
 var SwipeLength, swipeAngle, swipeDirection, legalSwipe = false;
 var swipeMinLength = 20;

 Label2.ontouchstart = function() {
     swStartX = event.touches[0].pageX;
     swStartY = event.touches[0].pageY;
 };

 Label2.ontouchmove = function() {
     swCurX = event.touches[0].pageX;
     swCurY = event.touches[0].pageY;
 };

 Label2.ontouchend = function() {
     if (swCurX != 0) {
         SwipeLength = Math.round(Math.sqrt(Math.pow(swCurX - swStartX, 2) + Math.pow(swCurY - swStartY, 2)));
         if (SwipeLength >= swipeMinLength) {
             calcAngle();
             determineSwipeDir();
    //         processSwipe();
         }
     }
     TouchCancel();
 };

 function TouchCancel() {
     swStartX = 0;
     swStartY = 0;
     swCurX = 0;
     swCurY = 0;
     SwipeLength = 0;
     swipeAngle = null;
     swipeDirection = null;
     legalSwipe = false;
 }

 // calculate the angle
 function calcAngle() {
     var calX = swStartX - swCurX;
     var calY = swCurY - swStartY;
     var calZ;
     var calR;
     calZ = Math.round(Math.sqrt((calX * calX) + (calY * calY))); // the distance - rounded - in pixels
     calR = Math.atan2(calY, calX); // angle in radians
     swipeAngle = Math.round(calR * 180 / Math.PI); // angle in degrees
     if (swipeAngle < 0) {
         swipeAngle = 360 - Math.abs(swipeAngle);
     }
 }

 // determine swipe direction - left, right up down...
 function determineSwipeDir() {
     if ((swipeAngle <= 45) && (swipeAngle >= 0)) {
         swipeDirection = "left";
       //  Label6.textContent = "Swipe!";
         ChangeForm(Form4);  // move in frmRight
     } else if ((swipeAngle <= 360) && (swipeAngle >= 315)) {
         swipeDirection = "left";
        // Label6.textContent = "Swipe!";
         ChangeForm(Form4);  // move in frmRight
     } else if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
         swipeDirection = "right";
        // Label6.textContent = "Swipe!";
         ChangeForm(Form3);   //move in frmLeft
     } else if ((swipeAngle > 45) && (swipeAngle < 135)) {
         swipeDirection = "down";
       //  Label6.textContent = "Swipe!";
       } else {
       //  Label6.textContent = "Swipe!";
         swipeDirection = "up";
     }
 }

 function processSwipe() {
     // only see this with up or down swipe - otherwise changing forms
     NSB.MsgBox(swipeDirection);
 }

#2

Have you tried putting some console.log() statements in your code, so you can trace what is happening in the Chrome Debugger?