什么闪光事件可以中断MOUSE_UP事件,以及如何检测到它们? [英] What flash events can interrupt a mouse_up event, and how do I detect them?
问题描述
简化的code:
//triggered on MouseEvent.MOUSE_DOWN
private function beginDrag(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, drag);
stage.addEventListener(MouseEvent.MOUSE_UP, endDrag);
stage.addEventListener(Event.DEACTIVATE, endDrag);
contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, endDrag);
}
private function drag(e:MouseEvent):void
{
//do stuff
}
private function endDrag(e:Event):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, drag);
stage.removeEventListener(MouseEvent.MOUSE_UP, endDrag);
stage.removeEventListener(Event.DEACTIVATE, endDrag);
contextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, endDrag);
}
我是用我的内闪code一些点击和拖动技术,而且我发现一些漏洞与MOUSE_UP事件:
I am using some click-and-drag techniques within my flash code, and I've noticed some loopholes with the MOUSE_UP event:
- 在它不会被触发,如果上下文菜单被激活,而鼠标依旧保持了下来。
- 它不会如果窗口被关闭(ALT + TAB或类似) 触发
我的问题是: 什么其他活动都不可能中断MOUSE_UP事件,并会导致意外行为?
My question is: What other events can possibly interrupt the MOUSE_UP event and lead to unexpected behavior?
此外,有没有办法来一般捕捞ContextMenuEvent.MENU_SELECT为的所有的上下文菜单,无需手工添加/删除听众每个上下文菜单?
Additionally is there a way to generically catch ContextMenuEvent.MENU_SELECT for all context menus without having to manually add/remove the listeners to each context menu?
推荐答案
它可能会为 Event.REMOVED_FROM_STAGE
或 Event.REMOVED
事件触发,如果编译的SWF是另一个SWF中的孩子。我相信,在那种情况下,所属文档的舞台被引用,并为此仍然不是一个问题。
It may be possible for the Event.REMOVED_FROM_STAGE
or Event.REMOVED
events to fire if the compiled swf is a child of another swf. I believe in that scenario, the owning document's stage is referenced, and therefor still not an issue.
FocusEvent.FOCUS_OUT
不触发直到在的用户已经放开鼠标,这将触发侦听MouseEvent.MOUSE_UP
事件。
FocusEvent.FOCUS_OUT
doesn't trigger until after the user has let go of the mouse, which would trigger the MouseEvent.MOUSE_UP
event.
看来我原来的code作品不够好。 (有漏洞的可能性,如果一个子元素的上下文菜单被触发)。
It seems my original code works well enough. (there is the possibility of a loophole if a sub-element's context menu is triggered).
这篇关于什么闪光事件可以中断MOUSE_UP事件,以及如何检测到它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!