AS3 mouseEnabled not working with nested Movieclips

Had a little bit of a problem with mouseEnabled= false not working.

I had two movieclips. One was a button and one a ‘tooltip’ mc that was on top of the button. The button mc had mouseEvent listeners for mouseover and mouseout. Now the standard thing to do to stop recieving mouse interactivity on a display object is to set mouseEnabled = false. (It is set to true by default and stops you pressing ‘thru’ display objects) However it was not working. In my setup i had nested Moviclips but i had assumed setting this on the parent would affect all mouse ‘enabling’

The thing to use is:

mouseEnabled = false; //as well as
mouseChildren = false;

this should tell actionscript to stop listening to nested mc’s as well.

Leave a Reply

  1. Matt Schneck

    Ah, thanks for this. I had a navigation dropdown window that I was having this problem with, and I kept ending up triggering movieclips that should have been un-clickable…you made my headache go away! Thanks!

  2. Ryan Terry

    I figured out how to fix this issue. You need to set the parent’s mouseEnabled = false.

    parentClip.mouseEnabled = false;
    parentClip.childClip.mouseEnabled = false;
    parentClip.childClip.mouseChildren = false; //I add this just to make sure nothing inside works

  3. jb

    my problem looks similar to yours, but since what you’ve proposed doesn’t work for me (at leas the way i may have incorrectly applied it), i’ll give you a brief description and hopefully you can help me.

    i just want to execute button actions, which allow one nested movie to effect its “parent”, “uncle” and “great uncle” movie clips (sorry for my non-precise hierarchical terms).

    i already know that actions are no longer assigned to symbols, but rather to the first frame of a time line. i also feel i know how to use current dot syntax to identify a symbol’s location within the hierarchy tree, as well as how to use “addEventListener”.

    i believe that the only additional fix i need is to have some simple string of code, which allows flash to recognize these nested symbols as movies. i’m not sure about the terminology i’m using, but i believe, from my research, that the solution involves using “trace”, “mouseChildren” or “mouseEnabled” (as you did for this purpose?).

    anyway, i’ll show you what i did, so you can take a look. first off, here is the symbol hierarchy:

    scene 1: main movie timeline
    …- mb (movie clip)
    …..+ mbon (parent of button in question)
    …….* tog (button in question)
    …..+ mbse (“uncle” of button in question)
    …- s1 (“great uncle” of button in question)

    and here is the as3 action script that i assigned to the first frame of the main timeline:

    mb.mbon.tog.mouseEnabled = false;
    s1.mouseEnabled = false;
    mb.mbse.mouseEnabled = false;
    mb.mbon.mouseEnabled = false;
    mb.mbon.tog.mouseChildren = false;
    s1.mouseChildren = false;
    mb.mbse.mouseChildren = false;
    mb.mbon.mouseChildren = false;

    root.mb.mbon.tog.addEventListener(MouseEvent.CLICK,
    fl_ClickOnToSe);

    function fl_ClickOnToSe(event:MouseEvent):void
    {
    root.s1.gotoAndStop(“se”);
    root.mb.mbse.gotoAndStop(“on”);
    root.mb.mbon.gotoAndStop(“off”);
    }

    i believe i just need to know what code to write and where to place it. anything you can do to either correct what i’ve done or add to it, or any suggestions of elsewhere i can look would be greatly appreciated. thank you thanks for considering helping out a stranger!

  4. Simon Rawicz

    Hi Jeff, I noticed having similarly battled between mouse bleed’s was that alternating between MOUSE_OVER and ROLL_OVER also gave for better control, combined with stringent mouseChildren regulation they both complemented each other and helped resolve many issues…

    Keep up the good work!

Posted