MovieClip transparency to mouse click

Before ActionScript 3 came, when you had a MovieClip over a button, if that MovieClip didn’t have any mouse function (onRelease, onRollOver, etc) you could interact with the button underneath. Most of the time this was an unwanted behavior that you had to circumvent by putting an invisible button in your MovieClip and use the useHandCursor =  false line of code.

Well in Flash 9, it doesn’t work that way anymore, if you have a displayObject in front of a button (or displayObject with mouseEvent listeners), it will block the mouse events from happening. That’s really nice in most cases, you don’t have to do the invisible button anymore. But in the project that I just released I had these PNGs with a lot of transparency, so you could see the button underneath. The thing is that you couldn’t interact with the button because of what I just explained earlier. I looked the documentation a bit and I found this property of the DisplayObject: mouseEnabled which is useful in these situations. When you set mouseEnabled to false, your MovieClip, Sprite, DisplayObject will be transparent to mouse events like clicks, rollOvers etc. That way button that are under the DisplayObject with mouseEnabled=false can still work.

Another neat thing with that is that DisplayObject inside the DisplayObject with mouseEnabled=false can still have mouse events. So it’s pretty customizable and useful.

8 Responses to “MovieClip transparency to mouse click”

  1. Sean Says:

    Thanks man!

  2. felix Says:

    Note setting ‘mouseEnabled’ to false doesn’t work for nested movieclips. To make nested mcs mouse transparent set the parent mc’s ‘mouseChildren’ to false.

  3. K9 Says:

    Well,
    first let me say that should this work for me, once I have tried it, I will be one glad person, for I have been looking for a solution to a similar problem.

    My problem has to do with my mostly-transparent-FLEX App blocking all mouse events from reaching the HTML behind it.

    Do you think that this will work for me aswell?

  4. dgelineau Says:

    I don’t know if it will solve your problem, but it sure is worth the try. That’s the first thing I would do.

  5. Ryan Says:

    Nice.. I was about the come up with a crazy scheme to get around my issue, but this worked like a charm.

  6. de Says:

    Thanks man!

  7. Tunç Atakan Says:

    Perfect. You saves my hours… Thanx…

  8. Victor Says:

    please help!!, i have i big movie clip that is showing some photos on movment and have his own rolover and out codes for stop and play, each photo its a movie clip wiht buttons, in the main scene in front of all the big mc i have a movie clip that shows the photo in big size, but when i mouse over it work but only in the sides that the mc its not hinder but when im in the middle were is the movie clip it dosent work it get disturbes i dont know whats happen, did i use visible = false codes? hope you can help me.
    here its the code,,, i use your code but i dont know if its ok.

    thank you for your time
    regards.

    DisplayObject: mouseEnabled = false

    slides_mc.slide_mc.NuevoMov_mc.addEventListener(MouseEvent.ROLL_OVER, rolover);
    slides_mc.slide_mc.NuevoMov_mc.addEventListener(MouseEvent.ROLL_OUT, rollout);

    function rolover(gunoi:MouseEvent):void {
    NuevoMov_mc.removeEventListener(Event.ENTER_FRAME,rewind);
    NuevoMov_mc.gotoAndPlay(2);
    }
    function rollout(goz:MouseEvent):void {
    NuevoMov_mc.addEventListener(Event.ENTER_FRAME, rewind);
    }
    function rewind(rewinds:Event):void {
    NuevoMov_mc.prevFrame();
    }

Leave a Reply


Close
E-mail It