2013年4月14日 星期日
AS3筆記 - 行動平台手指事件
點擊
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
square.addEventListener(TouchEvent.TOUCH_TAP, tapHandler);
function tapHandler(e:TouchEvent):void
{
}
_______________________________________________________________________________
拖曳
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
stage.addEventListener(TouchEvent.TOUCH_BEGIN, touchBeginHandler);
function touchBeginHandler(e:TouchEvent):void
{
}
stage.addEventListener(TouchEvent.TOUCH_END, touchEndHandler);
function touchEndHandler(e:TouchEvent):void
{
}
_______________________________________________________________________________ 長按
var CLICKTimer:Timer = new Timer(1000);
CLICKTimer.addEventListener(TimerEvent.TIMER, pressTimerHandler);
function pressTimerHandler(e:TimerEvent):void
{
}
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
stage.addEventListener(TouchEvent.TOUCH_BEGIN, pressBeginHandler);
function pressBeginHandler(e:TouchEvent):void
{
CLICKTimer.start();
}
stage.addEventListener(TouchEvent.TOUCH_END, pressEndHandler);
stage.addEventListener(TouchEvent.TOUCH_ROLL_OUT, pressEndHandler);
function pressEndHandler(e:TouchEvent):void
{
CLICKTimer.stop();
}
_______________________________________________________________________________
雙擊
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(GestureEvent.GESTURE_TWO_FINGER_TAP, twoFingerTapHandler);
function twoFingerTapHandler(e:GestureEvent):void
{
}
_______________________________________________________________________________
縮放
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, zoomHandler);
function zoomHandler(e:TransformGestureEvent):void
{
obj.scaleX *= event.scaleX;
obj.scaleY *= event.scaleY;
}
_______________________________________________________________________________
旋轉
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ROTATE, rotateHandler);
function rotateHandler(e:TransformGestureEvent):void
{
e.target.rotation += event.rotation;
}
_______________________________________________________________________________
上下左右滑動
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, swipeHandler);
function swipeHandler(e:TransformGestureEvent):void
{
switch(e.offsetX)
{
case 1:
{
// 右
break;
}
case -1:
{
// 左
break;
}
}
switch(e.offsetY)
{
case 1:
{
// 下
break;
}
case -1:
{
// 上
break;
}
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言