鼠标移动触发鼠标单击 (Adobe Air)

发布于 2024-12-09 12:27:55 字数 398 浏览 1 评论 0原文

我试图在 SpriteVisualElement 上有两个客人,我认为这应该非常简单地实现:

用于扫描手势的 Mouse_Move 和鼠标单击以启用..

所以我的舞台上有 2 个事件侦听器:

stage.addEventListener(MouseEvent.CLICK, taphandler);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mousedownhandler);

主要问题是每种类型的扫描screen 还会触发 Taphandler()..

关于如何识别正确的事件有什么想法吗?

我尝试仅使用 if(!event.buttondown) 来处理我的 Taphandler,但没有成功。

I am trying to have two guestures on a SpriteVisualElement which I thought should be pretty simple implemented:

Mouse_Move for sweep Gestures and mouse click to enable..

So I have 2 Eventlisteners on my stage:

stage.addEventListener(MouseEvent.CLICK, taphandler);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mousedownhandler);

The main problem is that every type of sweeping on the screen also fires the taphandler()..

Any ideas on how to identify the correct event?

I tried to to my taphandler only if(!event.buttondown) but no success.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞美少年 2024-12-16 12:27:55

您需要专门处理MouseEvent.CLICK吗?或者您只是想分别处理点击和拖动。如果是这种情况,请尝试以下两种方法之一进行点击:(

MySprite.addEventListener(TouchEvent.TOUCH_TAP, taphandler);
MySprite.addEventListener(PressAndTapGestureEvent.GESTURE_PRESS_AND_TAP, taphandler);

请注意,这些事件处理程序位于您的精灵上,而不是舞台上)

对于触摸和拖动,请尝试:

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

MySprite.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
MySprite.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
MySprite.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);

function onTouchBegin(eBegin:TouchEvent) {
     eBegin.target.startTouchDrag(eBegin.touchPointID, false, bg.getRect(this));
     trace("touch begin");

 }

function onTouchMove(eMove:TouchEvent) {
    trace(eMove.stageX);
}

function onTouchEnd(eEnd:TouchEvent) {
     eEnd.target.stopTouchDrag(eEnd.touchPointID);
     trace("touch end");
}

您可能遇到的唯一问题是 TouchEvent.TOUCH_TAP和 TouchEvent.TOUCH_BEGIN 在您的设备上都可能被解释为 MouseClick.TOUCH,因此,如果您的精灵上附加了 MouseClick.TOUCH 的处理程序,则会发生冲突。

顺便说一句,大部分信息来自 Adobe Actionscript 3.0 参考 - TouchEvent

Do you need to handle MouseEvent.CLICK specifically? Or are you just trying to handle a tap and a drag separately. If this is the case, try one of these two for a tap:

MySprite.addEventListener(TouchEvent.TOUCH_TAP, taphandler);
MySprite.addEventListener(PressAndTapGestureEvent.GESTURE_PRESS_AND_TAP, taphandler);

(note that these event handlers are on your sprite, and not the stage)

For touch and drag, try:

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

MySprite.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
MySprite.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
MySprite.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);

function onTouchBegin(eBegin:TouchEvent) {
     eBegin.target.startTouchDrag(eBegin.touchPointID, false, bg.getRect(this));
     trace("touch begin");

 }

function onTouchMove(eMove:TouchEvent) {
    trace(eMove.stageX);
}

function onTouchEnd(eEnd:TouchEvent) {
     eEnd.target.stopTouchDrag(eEnd.touchPointID);
     trace("touch end");
}

The only issue you may run into is that TouchEvent.TOUCH_TAP and TouchEvent.TOUCH_BEGIN both might be interpreted as MouseClick.TOUCH on your device, so if you have a handler attached to your sprite for MouseClick.TOUCH, you will have a conflict.

BTW, most of this info is from the Adobe Actionscript 3.0 Reference - TouchEvent

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文