Actionscript 3 我只想将TransformGestureEvent.手势滑动添加到我的movieclip Rec_mc实例中,而不是stage,但它不起作用
手势事件不会局限于舞台上的特定MC,因为手势可能占据整个屏幕或传感器的尺寸。因此,做一个好的程序员,将侦听器注册到stage,并根据应用程序的当前状态解析手势Actionscript 3 我只想将TransformGestureEvent.手势滑动添加到我的movieclip Rec_mc实例中,而不是stage,但它不起作用,actionscript-3,flash,Actionscript 3,Flash,手势事件不会局限于舞台上的特定MC,因为手势可能占据整个屏幕或传感器的尺寸。因此,做一个好的程序员,将侦听器注册到stage,并根据应用程序的当前状态解析手势 /* Swipe Event Swiping the stage executes a function containing your custom code. You can use this event to scroll text in a TextField or change states in your applicatio
/* Swipe Event
Swiping the stage executes a function containing your custom code. You can use this event to scroll text in a TextField or change states in your application.
Instructions:
1. Add your custom code on a new line after the lines that say "// Start your custom code" below.
*/
Multitouch.inputMode = MultitouchInputMode.GESTURE;
Rec_mc.addEventListener(TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler);
function fl_SwipeHandler(event:TransformGestureEvent):void
{
switch(event.offsetX)
{
// swiped right
case 1:
{
// Start your custom code
// This example code moves the selected object 20 pixels to the right.
Rec_mc.x += 20;
trace("swipe right");
// End your custom code
break;
}
// swiped left
case -1:
{
// Start your custom code
// This example code moves the selected object 20 pixels to the left.
Rec_mc.x -= 20;
trace("swipe left");
// End your custom code
break;
}
}
switch(event.offsetY)
{
// swiped down
case 1:
{
// Start your custom code
// This example code moves the selected object 20 pixels down.
Rec_mc.y += 20;
trace("swipe down");
// End your custom code
break;
}
// swiped up
case -1:
{
// Start your custom code
// This example code moves the selected object 20 pixels up.
Rec_mc.y -= 20;
trace("swipe up");
// End your custom code
break;
}
}
}
您好,谢谢您的评论,这是滑动movieclip以执行特定动作的任何方法吗?因此,您想注册手势位置,并确定该位置滑动的对象是什么?我不认为这是可能的,因为手势太大了,无法从逻辑上确定它们要影响的对象。我会说点击并监听MouseEvent.MOUSE\u拖动事件。是的,使用stage构建一个滑动触摸解释器。您也可以在按钮或剪辑上使用触摸事件来检查是否有东西被触摸或点击。
if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE,init);
function init(e:Event=null):void {
removeEventListener(Event.ADDED_TO_STAGE,init);
stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler);
}