Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3: MOUSE_OUT not firing when Mouse leaves stage
    text
    copied!<p>I am developing a website with nav items that cover the whole stage from top to bottom (see altered image below) and it is pretty easy for the user to exit the stage with their mouse, not triggering the <code>MouseEvent.MOUSE_OUT</code> events required to "turn off" said nav items.</p> <p>Should I be using <code>Event.MOUSE_LEAVE</code> to detect when the mouse has left the stage, and turn off any enabled nav items? That is what I been trying to do, but have had trouble getting any output from my listener. Any ideas?</p> <p><a href="http://marcysutton.com/blog/wp-content/uploads/2010/01/redpropeller.png" rel="nofollow noreferrer">alt text http://marcysutton.com/blog/wp-content/uploads/2010/01/redpropeller.png</a></p> <p>For a class associated with a movieclip in the Flash IDE, is this the correct syntax for registering an <code>Event.MOUSE_LEAVE</code> listener? It doesn't seem to do anything no matter what I do. Is it a case where I have to embed the movie in a browser for the event to fire?</p> <pre><code>this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener); </code></pre> <p>Here is my MainNav.as class:</p> <pre><code>package com.redpropeller { import com.greensock.*; import com.greensock.plugins.*; import flash.display.*; import flash.text.*; import flash.events.*; public class MainNav extends MovieClip { // MainNav is a movieclip in the IDE public var colors:Array; public function MainNav():void { colors = new Array(0xee3124, 0xc72a1f, 0xa62c24, 0x912923, 0x7e221c); TweenPlugin.activate([TintPlugin]); // trying to target stage through this object this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener); for(var i:Number=0; i&lt;this.numChildren; i++){ var n = this.getChildAt(i); n.useHandCursor = true; n.buttonMode = true; n.addEventListener(MouseEvent.MOUSE_OVER, navBtnOn); n.addEventListener(MouseEvent.MOUSE_OUT, navBtnOff); } } public function mouseLeaveListener(e:Event):void { trace('mouseleave'); // nothing ever happens } private function navBtnOn(e:MouseEvent):void { TweenLite.to(e.currentTarget.bar_mc, 0.01, {tint:0x333333}); } private function navBtnOff(e:MouseEvent):void { TweenLite.to(e.currentTarget.bar_mc, 0.01, {tint:uint(colors[this.getChildIndex(MovieClip(e.currentTarget))])}); // changes color back to specific tint } } } </code></pre>
 

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