ActionScript 3 鼠标按下
我如何不断检查鼠标是否按下,如果鼠标按下并且移动,我
尝试了 mk_mc.addEventListener(MouseEvent.MOUSE_DOWN,fct) 函数,但它只调用函数,然后停下来,我想不断地做,我该怎么做?
How could I check constantly whether mouse is down and if mouse is down and it moves that I cal a function
I tried mk_mc.addEventListener(MouseEvent.MOUSE_DOWN,fct)
but it only calls the function ones and then stops, I want to do it constantly, how can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您所要求的内容以前已经被要求过,但我很难找到重复的问题,因此我将发布我所在问题的链接就一些利基问题寻求帮助。
在 AS3 中处理拖动事件的一些合理代码是:
What you're asking for has been asked for before, but I can't easily find a duplicate question, so I'll post the link to my question where I was asking for help with a few niche issues.
Some reasonable code for handling drag events in AS3 is:
那么你想要做的是当鼠标移动并且按钮按下时调用一个函数?
最简单的方法是在鼠标移动时调用该函数(或者如果您想在鼠标未移动时调用该函数,则使用计时器),并让它在执行任何操作之前检查由鼠标向上/向下设置的标志行动。
So what you want to do is call a function when the mouse moves and the button is down?
The easiest way is to call the function on mouse move (or use a Timer if you want to call the function even when the mouse isn't moving), and have it check a flag set by the mouse up/down before it takes any action.
我认为您可以简单地在鼠标按下时设置一些标志,并在鼠标抬起时再次将其设置回来。像这样:
然后只需轮询
down_
即可知道鼠标是否按下。I think you could simply set some flag when the mouse is down and set it back again when the mouse is up. Something like that:
Then just poll
down_
to know if the mouse is down or not.