Note that there are some explanatory texts on larger screens.

plurals
  1. POdifferent MOUSE_OUT behavior for vertical and horizontal moves?
    text
    copied!<p><code>MOUSE_OUT</code> events are, evidently, handled differently for X and Y mouse moves when leaving a Sprite. </p> <p><em>How do I fix this or work around it? Where is this documented?</em></p> <p><code>MOUSE_OUT</code> occurs when <code>x==0</code>, but not <code>y==0</code> (you need to go to <code>y==-1</code>):</p> <pre><code>private var _sp:Sprite; public function test( ):void { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; _sp = new Sprite( ); _sp.graphics.beginFill( 0xFF0000, 1 ); _sp.graphics.drawRect( 0, 0, 15, 15 ); _sp.graphics.endFill( ); _sp.x = 10; _sp.y = 10; _sp.alpha = 1; addChild( _sp ); _sp.addEventListener( MouseEvent.MOUSE_MOVE, msMvCb, false, 0, true ); _sp.addEventListener( MouseEvent.MOUSE_OUT, msOutCb, false, 0, true ); } private function msMvCb( evt:MouseEvent ):void { traceMousePos( "mv", evt ); _sp.alpha = 1; } private function msOutCb( evt:MouseEvent ):void { traceMousePos( "out", evt ); _sp.alpha = .5; } private function traceMousePos( note:String, evt:MouseEvent ):void { trace( note + " -- " + evt.localX + ", " + evt.localY + ", " + evt.stageX + ", " + evt.stageY ); } </code></pre> <p>Here is a trace from moving straight up, with <code>MOUSE_OUT</code> on -1 ...</p> <pre><code>mv -- 7, 3, 17, 13 mv -- 7, 2, 17, 12 mv -- 7, 1, 17, 11 mv -- 7, 0, 17, 10 out -- 7, -1, 17, 9 </code></pre> <p>And here is a trace from moving straight to the left, with <code>MOUSE_OUT</code> on 0 ...</p> <pre><code>mv -- 3, 7, 13, 17 mv -- 2, 7, 12, 17 mv -- 1, 7, 11, 17 out -- 0, 7, 10, 17 </code></pre> <p><em>edit</em></p> <p>The same errant behavior occurs with MOUSE_ENTER.</p>
 

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