air手势代码

//下列2句谁放上面谁生效要么触控生效,要么手势生效
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
Multitouch.inputMode = MultitouchInputMode.GESTURE; //***************************轻点触控************************************
tap.addEventListener(TouchEvent.TOUCH_TAP, tapHandler);
function tapHandler(event:TouchEvent):void
{
trace("tap");
} //***************************拖拽触控************************************ drag.addEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler);
var fl_DragBounds:Rectangle = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
function touchBeginHandler(event:TouchEvent):void
{
event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds);
trace("drag_Begin");
}
drag.addEventListener(TouchEvent.TOUCH_MOVE, touchmoveHandler);
function touchmoveHandler(event:TouchEvent):void
{
trace("dragging");
}
drag.addEventListener(TouchEvent.TOUCH_END, touchEndHandler);
function touchEndHandler(event:TouchEvent):void
{
event.target.stopTouchDrag(event.touchPointID);
trace("drag_End");
} //***************************长按触控************************************
var pressTimer:Timer = new Timer(1000);
pressTimer.addEventListener(TimerEvent.TIMER, pressTimerHandler);
function pressTimerHandler(event:TimerEvent):void
{
trace("长按");
} long_tap.addEventListener(TouchEvent.TOUCH_BEGIN, pressBeginHandler);
function pressBeginHandler(event:TouchEvent):void
{
pressTimer.start();
}
long_tap.addEventListener(TouchEvent.TOUCH_END, pressEndHandler);
long_tap.addEventListener(TouchEvent.TOUCH_ROLL_OUT, pressEndHandler);
function pressEndHandler(event:TouchEvent):void
{
pressTimer.stop();
} //***************************双指手势************************************ Two_Finger_Tap.addEventListener(GestureEvent.GESTURE_TWO_FINGER_TAP, twoFingerTapHandler);
function twoFingerTapHandler(event:GestureEvent):void
{
trace("双指");
Two_Finger_Tap_text.text="双指";
} //***************************缩放手势************************************ scale.addEventListener(TransformGestureEvent.GESTURE_ZOOM, zoomHandler);
function zoomHandler(event:TransformGestureEvent):void
{
scale.scaleX *= event.scaleX;
scale.scaleY = scale.scaleX;
} //***************************平移手势************************************ pan.addEventListener(TransformGestureEvent.GESTURE_PAN, panHandler);
function panHandler(event:TransformGestureEvent):void
{
event.currentTarget.x += event.offsetX;
event.currentTarget.y += event.offsetY;
} //***************************旋转手势************************************ rotat.addEventListener(TransformGestureEvent.GESTURE_ROTATE, rotateHandler);
function rotateHandler(event:TransformGestureEvent):void
{
event.target.rotation += event.rotation;
} //***************************滑动手势************************************ swipe.addEventListener(TransformGestureEvent.GESTURE_SWIPE, swipeHandler);
function swipeHandler(event:TransformGestureEvent):void
{
switch (event.offsetX)
{
case 1 :
{
trace("右滑");
swipe_text.text="右滑";
break; };
case -1 :
{
trace("左滑");
swipe_text.text="左滑";
break; }
};
switch (event.offsetY)
{
case 1 :
{
trace("下滑");
swipe_text.text="下滑";
break; };
case -1 :
{
trace("上滑");
swipe_text.text="上滑";
break; }
}
};

  

上一篇:Lambda表达式图解


下一篇:java面试每日一题13