检测舞台上的 mouseUp
有没有办法检查已附加到舞台的方法?
我的舞台是全局的..并且需要在 mouseup 上的对象中触发一些功能... 现在它会触发 2 或 3 个,具体取决于我添加的对象数量。
我需要类似的东西。
if($.stage.hasEventListener(MouseEvent.MOUSE_UP, this.mouseUp) === false){ $.stage.addEventListener(MouseEvent.MOUSE_UP, this.mouseUp); 或者
有更好的方法来处理这个问题?
Is there a way to check the method that has been attached to the stage?
I have stage as global.. and need to fire some function in a object on mouseup...
Now it fires 2 or 3 depending how many objects i add..
I need something like..
if($.stage.hasEventListener(MouseEvent.MOUSE_UP, this.mouseUp) === false){
$.stage.addEventListener(MouseEvent.MOUSE_UP, this.mouseUp);
}
Or a better way to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您正在每个对象中添加侦听器,不是吗?这意味着每次创建对象的实例时,您都会为舞台鼠标释放事件添加另一个侦听器。如果您确实只需要此类事件的单个侦听器,请将其移到对象范围之外,并且仅添加侦听器一次。祝你好运!
I'm guessing you are adding the listener inside each object, no? That means every time you create an instance of your object you are adding yet another listener for stage mouse up events. If you really only want a single listener for this type of event, move it outside of the scope of the object and only add the listener once. Good luck!