The more I learn about AS3 the more I enjoy it... however, figuring out all the little insider tricks can be aggravating.
My current struggle has been with the mouse enabled feature. Basically if you click on the screen, Flash will register the click with the top layer regardless if that top layer is being used or not. My current application contains many gradients, masks, and transparent layers and since it was not my design I sometimes do not even realize they are there. I may have a button that I can see plain as day (who came up with that quote? and better yet, who still uses it?). But I can not click on this button because of some masked/transparent evil movieclip that is on top of the button. So I dig through the layers and try to find this evil movieclip that was created to cause me misery and I set its mouseEnabled to false... which basically means the mouse ignores this layer and checks the next layer. You'd think that would solve it, and in some cases it does.
However, there is a catch. What if this evil layer is so clever that it had another invisible evil layer hidden within it as a child. Well shat... My first reaction was to dig through each child and set the mouseEnabled to false. However, Flash comes to the rescue with mouseChildren. Basically if you set mouseChildren to false then Flash will ignore the mouse clicks of all the children of that Movieclip.
Even with all this grief I do have to admit I prefer this setup over having movieclips being accidentally clicked in the background (which occurred frequently in previous versions of flash).
Friday, April 25, 2008
mouseEnabled vs mouseChildren
Subscribe to:
Post Comments (Atom)


5 comments:
Thanks for an interesting article. But there is one thing I still kept wondering - why not use mouseChildren all the time? If you deactivate clickability on a MovieClip, 99.9% of the time you would want to disable clickability for any element inside that mc.
You are probably right. I've been using mouseEnabled when the item does not have children and using mouseChildren when it does. But honestly I do not know if there is any optimization boost for doing this. It just seemed like a good practice, but could be completely unnecessary.
Just as an extra note, it looks like you have to use both mouseEnabled and mouseChildren when you don't want the movie clip OR its children to catch mouse events.
Thanks for the pointer Mark. Really helped me get around a snagette I had with a project...thanks for sharing!
Cheers,
James
Thanks for the info. In regards as to why sometimes you'd want to have a movieclip mouse disabled but have its children active is if say you had a movieclip that you wanted to drag around, and then when locked in to place, have movieclips inside have mouse events. I recently needed that functionality to build an interactive map of a facility with icons inside of the draggable movieclip that needed rollover effects (to show info or animate), while making sure that if clicked on, the whole map wouldn't drag.
Post a Comment