Note that there are some explanatory texts on larger screens.

plurals
  1. POEvent.MOUSE_LEAVE not working in AS3
    primarykey
    data
    text
    <p>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?</p> <pre><code>stage.addEventListener(Event.MOUSE_LEAVE, traceMouse); function traceMouse(Evt:Event):void { trace("Mouse Left Stage"); } </code></pre> <p><strong>________________________________________________</strong></p> <p><strong>[EDIT]</strong> 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: </p> <p>Flash CS4 Professional ActionScript 3.0 Language Reference:</p> <blockquote> <p>Updated 8/11/09: Added qualification that event is not fired when button is pressed.<a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Stage.html#event:mouseLeave" rel="nofollow noreferrer">1</a></p> </blockquote> <p>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.</p> <pre><code> 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(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload