Sr.Richie
Sr.Richie

Reputation: 5740

Disable mouse event for a specific child of a movieclip

I've a MovieClip that contains lot of children. One of them is a big (and useless) shadow the graphic designer put there to make my life harder (and also the user's one, probably) :)

Now I'm facing a little issue: the shadow is catching the MouseEvents attached to the main MovieClip (its parent), and this is very bad because it's very distant from the rest of the graphic. I'm now trying to avoid it.

Obviously I've already tried to set the shadow mc's properties mouseEnabled and mouseChildren to false, but it doesn't work.

I've found a previous thread (here), facing the same situation. But the solution accepted looks like it's not working for me.

What I am missing?

Upvotes: 4

Views: 980

Answers (3)

Florian Lavorel
Florian Lavorel

Reputation: 784

Reading your question, I am assuming you already tried to set the parent MovieClip's mouseChildren to true with mouseEnabled to false and then set the children's mouseEnabled to true (except for the shadow). This solution should work in my opinion so I am guessing the event might be caught by one parent of your movieclip (you do not give much information about this).

Try to add a listener to the stage to see which object is receiving your MouseEvents:

import flash.utils.getQualifiedClassName;
stage.addEventListener(MouseEvent.CLICK, onClick);
private function onClick(event:MouseEvent):void
{
    trace(event.target.name, getQualifiedClassName(event.target));
}

Upvotes: 1

Rajneesh Gaikwad
Rajneesh Gaikwad

Reputation: 1193

If mouseEnabled and mouseChildren is not working for you then use e.target.name property.

But first you will have to give a name to that shadow MovieClip (say shadowMC).

If you added it dynamically then use,

yourDynamicMC.name = "shadowMC"

If added manually on the stage then give instance name as "shadowMC",

Then, inside your code where you have MouseEvent function for parent MovieClip add the following lines

if(e.target.name != "shadowMC")
{
    //Then proceed

}

Upvotes: 2

Benjamin BOUFFIER
Benjamin BOUFFIER

Reputation: 946

Try changing the hit area of your MovieClip. see the MovieClip doc here, this will override you MovieClip zone.

Upvotes: 0

Related Questions