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)