Mouse events on drawn/hidden objects
**** UPDATE ****
After a lengthy discussion with Tink over IM (you can see in my comment below), we determined that you don’t need to set the alpha to .0051 – this was a trick that Keith used with his Apollo app to make the BG clickable, but I assumed it was true for flash and never bothered to think past that 😉 You can set the alpha to 0 and still click on a Sprite on stage.
Now, I tried the suggestion of using a Sprite container and drawing in it, then assigning that as the hit area of a parent sprite container, but that was horribly slow compared to the blendMode method.
So, BlendMode, has shown to be the fastest of the 3 methods described here. Of course, causing the player to deal with alpha is going to cost you in CPU, so since BlendMode.ERASE essentially skips those calcs, it seems to be the fastest solution so far.
**** END UPDATE ****
Well, leave it to Carlos to come up with this little gem. I’d been at Keith Peter’s talk on “thinking outside the box” at FITC Toronto (which completely \m/), and one of the little gems I got from that (besides, bang/hole/shoot) was that the lowest alpha value you could set on a sprite and still have Mouse interactivity was .0051. Apparently, Keith sat there and entered in values until he hit a number that worked 🙂
*Note:Tink has helped me dispell this myth – .0051 was used for Keith’s Apollo app for the background, but is not necessary to do in flash for this type of thing. Setting alpha to 0 will allow you to interact with your containers.
Now, I’d used this little bit o’ happiness in InteractiveSceneManager with Papervision3D and it’s worked well. However, we knew this came at a price with the render.
Carlos just hit me with this work around by using BlendMode.ERASE on the sprite container – and it’s fast 🙂 He got the idea off of Tinic’s blog with a nice explanation of why it’s so much faster.
Anyway, for what I was doing, this was a rockin’ solution especially when we’re trying to preserve as much CPU for 3D as we can 😉
[as]var mc:MovieClip = new MovieClip();
mc.graphics.drawCircle(0, 0, 10)
mc.blendMode = BlendMode.ERASE;
Hope that helps, sorry for the confusion