Clicking Through MovieClips to Underlying Objects in ActionScript 3
Thursday, January 31st, 2008One new thing about ActionScript 3 documents that you may have noticed is a new behavior related to MovieClips. Prior to ActionScript 3, you could create a button on the stage, lay a MovieClip over it and click through the MovieClip to the button below. Now, at times this was cool – but at other times, like when you want to make an area go modal, it was a pain because you had to add a mouse event to the MovieClip that was the overlay or change that MovieClip to a button in order to prevent clicking through to the items behind/underneath it.ActionScript 3, by default prohibits you from clicking through a display object to items underneath. So, how do you get around that? I stumbled upon a quick explaination over at Reyco1’s Flash Blog. Check out the demo below… You will see that in order to click through the MovieClip to the button behind we need to set two properties: mouseEnabled and mouseChildren. The mouseEnabled property sets whether or not the mouse registers on the given clip while the mouseChildren sets whether children within the given clip register the mouse. Setting both of these properties to false ensures that we can click through the MovieClip to the elements below.