Event.MOUSE_LEAVE在AS3中不起作用 [英] Event.MOUSE_LEAVE not working in AS3

查看:119
本文介绍了Event.MOUSE_LEAVE在AS3中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是将这个超级简单的代码示例丢入了Flash CS4 IDE框架脚本中,但是在控制台中没有任何输出.我只是将鼠标悬停在窗口上,而不单击任何东西,因此没有任何反应.为什么这不能按我预期的那样工作?

I just tossed this super simple code example into a Flash CS4 IDE frame script, but it doesn't output anything in the console. I'm simply rolling over my mouse over the window, not clicking anything, and nothing is happening. Why doesn't this work as I expect?

stage.addEventListener(Event.MOUSE_LEAVE, traceMouse);

function traceMouse(Evt:Event):void
 {
 trace("Mouse Left Stage");
 }

________________________________________________

,我发现Event.MOUSE_LEAVE毫无用处.首先,它在测试环境中不起作用(至少在Mac OS X的Flash CS4上).其次,如果MouseEvent.MOUSE_DOWN当前处于活动状态,则不会触发:

i find Event.MOUSE_LEAVE incredibly useless. first, it doesn't work in the testing environment (on Flash CS4 for Mac OS X, at least). second, it doesn't fire if MouseEvent.MOUSE_DOWN is currently active:

Flash CS4 Professional ActionScript 3.0语言参考:

Flash CS4 Professional ActionScript 3.0 Language Reference:

更新8/11/09:增加了资格 当按钮为时,不会触发该事件 1

Updated 8/11/09: Added qualification that event is not fired when button is pressed.1

在我的特定情况下,我希望在拖动对象时触发MOUSE_LEAVE,以便在用户将其鼠标指针从舞台上拖出时触发stopDrag().由于这是不可能的,因此我决定在实际对象上使用MOUSE_OUT,而不是在对象的父对象或舞台上使用MOUSE_LEAVE.

in my particular situation, i wanted MOUSE_LEAVE to fire while i was dragging an object so that in the event the user drags his/her mouse pointer off of the stage it would fire stopDrag(). since that's not possible i've decided to use MOUSE_OUT on the actual object rather than MOUSE_LEAVE on the object's parent or stage.

 private function mouseDownHandler(evt:MouseEvent):void
  {
  object.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
  object.startDrag(false, pullBounds);
  }

 private function mouseUpHandler(evt:MouseEvent):void
  {
  object.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
  object.stopDrag();
  }

 private function mouseOutHandler(evt:MouseEvent):void
  {
  object.stopDrag();
  }

推荐答案

我认为此特定事件在创作环境中不起作用,请尝试发布HTML包装器并在浏览器中运行它.

I don't think this specific event works in the authoring environment, try publishing a html wrapper and running it in your browser.

这篇关于Event.MOUSE_LEAVE在AS3中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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