Issue with MOUSE_MOVE and MOUSE_OUT applied to stage

Posted by poepje on Stack Overflow See other posts from Stack Overflow or by poepje
Published on 2012-04-09T23:24:16Z Indexed on 2012/04/09 23:30 UTC
Read the original article Hit count: 222

Filed under:

I'm having an issue with MOUSE_OUT being called while it shouldn't. What I'm doing is quite simple: two images are shown when I move the mouse across the stage, and when the mouse leaves the stage they are hidden.

The problem is, that whenever the mouse hits the border of any movieclip on the stage, the MOUSE_OUT function gets called, hiding the two images. This means that whenever I move the mouse

My code (only the relevant parts are shown):

public class Slider extends MovieClip {
    var img1:Img1 = new Img1;
    var img2:Img2 = new Img2;
    var img1_hover:Img1_hover = new Img1_hover;
    var img2_hover:Img2_hover = new Img2_hover;

    public function Slider() {
        img1.alpha = 0;
        img2.alpha = 0;

        stage.addEventListener(MouseEvent.MOUSE_MOVE, showArrows);
    }
    function showArrows(e:MouseEvent) {
         img1.alpha = 1;
         img2.alpha = 1;

         stage.addEventListener(MouseEvent.MOUSE_OUT, hideArrows);
    }
    function hideArrows(e:MouseEvent) {
         img1.alpha = 0;
         img2.alpha = 0;
    }
 }

Flash throws no errors. I am using a separate .as file (just one) and have no code inside of the action panel in the .fla. Where there's stage.addEventListener, I also tried this., root. and nothing instead of stage.

© Stack Overflow or respective owner

Related posts about actionscript-3