如何在 as3 中执行滑动事件时停止触摸或单击事件
How to stop Touch or Click Event while Swipe Event is in action in as3
在我的代码中,我同时使用了滑动手势和点击事件。如何在滑动手势动作时避免点击事件或触摸事件?
stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler);
wall.tile[0].addEventListener(MouseEvent.CLICK, showBook());
wall.tile[1].addEventListener(MouseEvent.CLICK, showBook());
public function fl_SwipeHandler(event:TransformGestureEvent):void
{
switch(event.offsetY)
{
// swiped down
case 1:
{
if (swipe!=0){
Tweener.addTween(wall, {y: wall.y + 650, time:.5, transition:"easeOutSine" } );
swipe--;
}
// End your custom code
break;
}
// swiped up
case -1:
{
if (swipe<=(total/5)){
Tweener.addTween(wall, { y: wall.y - 650, time:.5, transition:"easeOutSine" } );
swipe++;
}
// End your custom code
break;
}
}
}
我通常在激活滑动时将一些布尔变量设置为 true,然后 tweener 的 onComplete 函数将其设置回 false。该布尔值是我的 onClick 函数中的一个条件(显然是假的):
public var swipeOn:Boolean;
public function fl_SwipeHandler(event:TransformGestureEvent):void{
switch(event.offsetY){
case 1:{
if (swipe!=0){
swipeOn = true;
Tweener.addTween(wall, {y: wall.y + 650, time:.5, transition:"easeOutSine", onComplete:doneSwipe } );
swipe--;
}
break;
}
case -1:{
if(swipe<=(total/5)){
swipeOn = true;
Tweener.addTween(wall, { y: wall.y - 650, time:.5, transition:"easeOutSine", onComplete:doneSwipe } );
swipe++;
}
break;
}
}
}
public function doneSwipe():void{
swipeOn = false;
}
public function showBook(Event:MouseEvent):void{
if(!swipeOn){
//....handle your clicks etc
}
}
在我的代码中,我同时使用了滑动手势和点击事件。如何在滑动手势动作时避免点击事件或触摸事件?
stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler);
wall.tile[0].addEventListener(MouseEvent.CLICK, showBook());
wall.tile[1].addEventListener(MouseEvent.CLICK, showBook());
public function fl_SwipeHandler(event:TransformGestureEvent):void
{
switch(event.offsetY)
{
// swiped down
case 1:
{
if (swipe!=0){
Tweener.addTween(wall, {y: wall.y + 650, time:.5, transition:"easeOutSine" } );
swipe--;
}
// End your custom code
break;
}
// swiped up
case -1:
{
if (swipe<=(total/5)){
Tweener.addTween(wall, { y: wall.y - 650, time:.5, transition:"easeOutSine" } );
swipe++;
}
// End your custom code
break;
}
}
}
我通常在激活滑动时将一些布尔变量设置为 true,然后 tweener 的 onComplete 函数将其设置回 false。该布尔值是我的 onClick 函数中的一个条件(显然是假的):
public var swipeOn:Boolean;
public function fl_SwipeHandler(event:TransformGestureEvent):void{
switch(event.offsetY){
case 1:{
if (swipe!=0){
swipeOn = true;
Tweener.addTween(wall, {y: wall.y + 650, time:.5, transition:"easeOutSine", onComplete:doneSwipe } );
swipe--;
}
break;
}
case -1:{
if(swipe<=(total/5)){
swipeOn = true;
Tweener.addTween(wall, { y: wall.y - 650, time:.5, transition:"easeOutSine", onComplete:doneSwipe } );
swipe++;
}
break;
}
}
}
public function doneSwipe():void{
swipeOn = false;
}
public function showBook(Event:MouseEvent):void{
if(!swipeOn){
//....handle your clicks etc
}
}