动作脚本3滑动功能(不会刷卡)脚本、动作、功能

2023-09-08 11:44:11 作者:柠檬不萌我很萌

我试图在AS3简单的刷卡动作(动作脚本3)。当我运行通过的Andr​​oid 3.6的测试我没有得到任何错误 - 但没有任何反应。该框不动。这里的code我使用...

I am trying to do a simple swipe motion in AS3 (action script 3). When I run the test through Android 3.6 I get no errors - but nothing happens. The box doesn't move at all. Here's the code I am using...

import flash.events.MouseEvent;

import flash.net.URLLoader;

import flash.ui.Multitouch;

import flash.ui.MultitouchInputMode;

import flash.events.TransformGestureEvent;

Multitouch.inputMode = MultitouchInputMode.GESTURE;

//Side Menu Swipe

smenu_mc.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);

//Top Menu Swipe

tmenu_mc.addEventListener(TransformGestureEvent.GESTURE_SWIPE, downSwipe);

function onSwipe (e:TransformGestureEvent):void{

    if (e.offsetX == 1){
        //Menu can only swipe to the right
        smenu_mc.x += 278;
    }
}

function downSwipe (e:TransformGestureEvent):void{

    if (e.offsetY == 1){
        //Menu can only swipe down
        tmenu_mc.y += 99;
    }
}

有谁知道这个问题?感谢您的帮助!

Does anyone know the issue? Thanks for the help!

推荐答案

最有可能的,你问题已经做焦点。

Most likely, you issue has to do with focus.

有关您的code的工作,你已经把它贴在刷取的听众对象必须有当前的焦点,以接收该事件。如果他们是离屏或刷卡前,用户不去碰它们,它们不会发出事件。

For your code to work, the objects you've attached the SWIPE listeners to have to have the current focus to receive the event. If they are off-screen or the user doesn't touch them before swiping, they won't dispatch the event.

尝试而不是增加听众的的阶段,这样的事件总是闪光无论刷卡开始的地方。

Try adding your listeners to the stage instead, that way the event will always fire no matter where the swipe started.

//Global Swipe
stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);

要滑动菜单,使用渐变库(如 TweenLite的为例)时,它的非常宽松

To slide your menus, it's very easing when using a tweening library (like TweenLite for example)

import com.greensock.TweenLite;
import com.greensock.easing.Quad;
import com.greensock.easing.Bounce;

function slideTopMenuIn(){
    TweenLite.to(tmenu_mc,2,{y: 0, ease: Bounce.easeOut});
}

function slideTopMenuOut(){
    TweenLite.to(tmenu_mc,1,{y: -tmenu_mc.height, ease: Ease.easeIn});
}

function slideSideMenuIn(){
    TweenLite.to(smenu_mc,2,{x: 0, ease: Bounce.easeOut});
}

function slideSideMenuOut(){
    TweenLite.to(smenu_mc,1,{x: -smenu_mc.width, ease: Ease.easeIn});
}

function downSwipe (e:TransformGestureEvent):void{

    if (e.offsetY == 1){
        slideTopMenuIn();
    }

    if(e.offsetY == -1){
        slideTopMenuOut();
    }

    if (e.offsetX == 1){
        slideSideMenuIn();
    }

    if(e.offsetX == -1){
        slideSideMenuOut();
    }
}