如何检查是否鼠标在影片剪辑? [英] How to check if mouse is over a MovieClip?

查看:228
本文介绍了如何检查是否鼠标在影片剪辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

否听众参与。的事情是,我可以使用 MOUSE_OVER MOUSE_OUT 的听众,但如果你在一个影片剪辑拖动鼠标快速够了,这些听众中的一个可能不被激活。我试了好几次。

No listeners involved. The thing is, I can use MOUSE_OVER and MOUSE_OUT listeners, but if you drag a mouse over a MovieClip quickly enough, one of these listeners may not be activated. I've tried it several times.

推荐答案

如果通过了​​速度不够快,那么也许在OS没有发送任何鼠标事件鼠标闪烁的那部分屏幕,摆在首位。移动鼠标快了很多比它的分辨率可以触发(或操作系统可以处理)将有你所看到的效果(而事实是,没有鼠标事件用于该部分画面处理),否则MOUSE_OVER一定会火(如果鼠标确实产生至少一个移动事件在影片剪辑)。

If the mouse passed by "quickly enough" then maybe the OS didn't send any mouse events to Flash for that portion of the screen, in the first place. Moving the mouse a lot faster than its resolution can fire (or the OS can handle) will have the effect you are witnessing (and the truth is, no mouse events were handled for that portion of the screen), otherwise MOUSE_OVER will surely fire (if the mouse does indeed generate at least one move event over a movie clip).

在MOUSE_OUT事件,但是,的可能的不是如果鼠标离开舞台区(叶闪存),因为不同的操作系统或浏览器的安全限制,火。

The MOUSE_OUT event, however, might not fire if the mouse leaves the stage area (leaves Flash), because of various OS or browser security limitations.

要解决此问题,注册监听器<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/EventDispatcher.html#event%3adeactivate"相对=nofollow>阶段:: flash.events.Event.DEACTIVATE 和<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#event%3amouseLeave"相对=nofollow>阶段:: flash.events.Event.MOUSE_LEAVE ,每一个雪碧/影片剪辑里面你也听了MOUSE_OUT,重复使用相同的处理函数。

To fix this, register listeners for stage::flash.events.Event.DEACTIVATE and stage::flash.events.Event.MOUSE_LEAVE, inside every Sprite/MovieClip you are also listening for MOUSE_OUT, reusing the same handler function.

MouseLeave事件(逐步解雇)是专门为您的问题产生:当指针移出舞台区域如果鼠标按钮pssed $ P $,该事件不会调度由Stage对象调度。 如果它触发时,你应该处理它像MOUSE_OUT在一个MOUSE_OVER状态任何影片剪辑(假定你有这样的状态)。如果鼠标按钮是pressed当它离开了舞台区,用户很可能会在某个时候释放出来并停用将火在舞台上,而不是。

The mouseLeave event (fired by stage) is especially created for your problem: "Dispatched by the Stage object when the pointer moves out of the stage area. If the mouse button is pressed, the event is not dispatched." If it fires, the you should handle it like MOUSE_OUT for any movieclip in a MOUSE_OVER "state" (supposedly you have such a state). If the mouse button was pressed when it left the stage area, the user will likely release it at some point and DEACTIVATE will fire on stage instead.

这篇关于如何检查是否鼠标在影片剪辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆