AS3 Basics: Disable Mouse Events on a Movieclip (pass through mouse events) in Actionscript 3

Hey all, in accordance with my new article writing regime, heres an article about a problem i came into contact with today.

I was working on a project for a client, i needed to have a watermark placed over an interactive area which used mouse events. Only the problem is that the watermark is a Movieclip (so i could use blend modes) which interferes with the underlying Movieclip’s mouse events.

So i fired up the livedocs and came across this handy inherited property for the MovieClip class “mouseEnabled”.

simply use the code below in you actions layer or class file and boom, the movieclip will no longer listen for mouse events nor stop Movieclips from behind it receiving them.

YourMovieClip.mouseEnabled = true;

Obviously where “YourMovieClip” place the instance name of your movieclip.

Stay cool
-Bill

Subscribe

Subscribe to our e-mail newsletter to receive updates.

  • http://www.ilike2flash.com ilike2flash

    Thanks, this post is very useful.

  • http://www.ricardocanelas.com Ricardo Canelas

    or…

    YourMovieClip.mouseEnabled = false;
    YourMovieClip.mouseChildren = false;

  • http://www.konturart.net kontur

    additionally, set the MC’s mouseChildren property to false to prevent any possible nested objects in the MC to receive (i.e. block) mouse events

  • nabercro

    mouseChildren… thanks!

  • timmerbear

    Thank! very useful.