Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Touch issue while drag or move object

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 558
    Comment on it

    If we move objects with touch.moved event then how can we differentiate the touch.begin and touch.moved event.

    This problem generate when we touch down on object and move it , now the correct flow should be that if touch.moved occur then object should not be click.

    So to differentiate this we have the code here        

    //country is an object on which we have add the touch event
    
            country.addEventListener(TouchEvent.TOUCH, onTouchIcon);
    
    
            private function onTouchIcon(evt:TouchEvent):void
            {
               var touch:Touch = evt.getTouch(this);
              //in touch.begin event we have take out the mouse pos       
    
                if(touch && touch.phase == TouchPhase.BEGAN)
                {
                    beginxPos = touch.globalX;
                    trace("TouchPhase.BEGAN "+ beginxPos);
                  }
    
          
                if(touch && touch.phase == TouchPhase.MOVED)
                {
                    trace("TouchPhase.MOVED");
                }
    
    //in touch.moved event we have take out the mouse pos       
                if(touch && touch.phase == TouchPhase.ENDED)
                {
                    endxPos = touch.globalX;
                    trace("TouchPhase.ENDED " + endxPos);
                 }
                    
            }
           private function insideCountry(evt:Event):void
            {
    
           //now we are comparing both touch.begin and touch.ended point difference and checking the      absolute value is greater then 20 , you can take (20) value as per your requirement.
    
    
                if(Math.abs(endxPos - beginxPos) > 20) return;
    
                   getAccessInsideCountry();
    
             }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: