ActionScript 3.0 TransformGestureEvent 和 MouseEvent

ActionScript 3.0 TransformGestureEvent and MouseEvent

我正在尝试使用 GESTURE_PAN 移动 MC 并使用 MOUSE_CLICK 转到另一帧。 许多人说 GESTURE_PAN 和 MOUSE_CLICK 一起工作,但他们不会在我的 iPhone 上工作。 我在网上阅读了很多问答,当然还有 Whosebug。

stop();

Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_PAN, onPan);
table.addEventListener(MouseEvent.CLICK, gotoBox);

function onPan(event: TransformGestureEvent): void
{
    table.x += event.offsetX;
    table.y += event.offsetY;
    if (table.x > (table.width / 2))
    {
        table.x = table.width / 2;
    }
    if (table.x < stage.stageWidth - (table.width / 2))
    {
        table.x = stage.stageWidth - (table.width / 2)
    }
    if (table.y > (table.height / 2))
    {
        table.y = table.height / 2;
    }
    if (table.y < stage.stageHeight - (table.height / 2))
    {
        table.y = stage.stageHeight - (table.height / 2)
    }
}
function gotoBox(e: MouseEvent)
{
    trace("mouse")
}

问题是当我在 Flash Pro CC 模拟器上测试它时一切正常但在我的 iDevice 上却不行。

帮帮忙,我运行没时间了!

有一个特殊的设置 mapTouchToMouse 标志来改变 MouseEvent 设备上的调度行为,默认情况下它设置为 true 所以除了触摸事件你还有鼠标事件。

但这主要是为了与 desktop/browser 应用程序向后兼容,并且在移动设备上有一定的性能开销,所以最好的做法是将该标志设置为 false 并使用一些 mouse/touch事件抽象,如 Starling touch system or Gestouch

因此请检查您是否将该映射更改为 false 某处,这是您没有鼠标事件的最可能原因。