MouseEnabled “not working” in flash as3. Solved

Spent half the night fighting that issue, I wanted to disable mouse clicks for TextFields on my gui HUD panel. So that I could click units beneath those text fields.

tf.mouseEnabled = false;//didnt work for me as well as
tf_parent.mouseEnabled = false;//and
tf_parent.mouseChildren = false;

the problem was that the panel sprite (parent of text fields) was intercepting mouse clicks..

The receipt:
– use this code to monitor who’s receiving the click

import flash.utils.getQualifiedClassName;

stage.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
{
trace(“clicktarget: “, event.target.name, getQualifiedClassName(event.target));
}

– and

tf.mouseEnabled = false;
tf_parent.mouseEnabled = false;

//and remove the hitArea for parent!!!!
tf_parent.hitArea = new Sprite();
tf_parent.hitArea.mouseEnabled = false;

Hope this helps somebody!

This entry was posted in Adobe Flash, as3, Coding faults collection, Game development. Bookmark the permalink.

4 Responses to MouseEnabled “not working” in flash as3. Solved

  1. Nick S. says:

    I LOVE YOU! I have been searching for forever, but I finally found this…Extremely helpful.
    Thanks very much!

  2. Alex Rhasto says:

    Dude, you made my day! <3 you. I saved a lot of time, thx for you. Gl.

  3. chad says:

    Thanks man, saved me a bunch of time. It’s always the little things like this that always take so long to debug.

  4. Darko says:

    Thanks! I been struggling with this issue for years! Always had to work around it with some crazy solutions

Comments are closed.