簡體   English   中英

ActionScript 3.0 TransformGestureEvent和MouseEvent

[英]ActionScript 3.0 TransformGestureEvent and MouseEvent

我正在嘗試使用GESTURE_PAN移動MC,還嘗試使用MOUSE_CLICK移至另一幀。 許多人說GESTURE_PAN和MOUSE_CLICK一起工作,但它們在我的iPhone上無法使用。 我已經在網絡上閱讀了很多問答,當然還有關於stackoverflow的文章。

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 Simulator上對其進行測試時,一切正常,但在我的iDevice上卻沒有。

救命,我沒時間了!

有一個特殊的設置mapTouchToMouse標志可以更改設備上的MouseEvent調度行為,默認情況下它設置為true因此除了觸摸事件之外,您還具有鼠標事件。

但這主要是為了與台式機/瀏覽器應用程序向后兼容,並且在移動設備上具有一定的性能開銷,因此最佳實踐是將標志設置為false並使用某些鼠標/觸摸事件抽象,例如Starling觸摸系統或Gestouch

因此,請檢查您是否在某處將該映射更改為false ,這是您沒有鼠標事件的最可能原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM