views:

285

answers:

1

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");
 }

____________________________

[EDIT] 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 Language Reference:

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

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();
  }
+1  A: 

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

grapefrukt
before posting i googled this issue. it seems that some people can't get it to work with the IDE, while others think they are crazy and it works for them no problem. could it possibly be a setting? and yes it does work for me when published in a browser
TheDarkInI1978
It might be OS dependent or something, I stay as far away as I can from flash authoring for code type stuff, so I never really run into this.
grapefrukt
that's a smart theory. i wouldn't be surprised if you were correct since MouseEvent.MOUSE_WHEEL doesn't work at all on Mac OS X (which is what i'm using)
TheDarkInI1978