PDA

View Full Version : Mouse Events for Invisible DisplayObjects


d000hg
01-10-2009, 10:49 AM
My experiments suggest a DisplayObject with visible=false doesn't receive mouse events, is this correct? If so, is there a way to force it to receive events? I have some invisible trigger areas in my game map that should respond to mouse activity and our content creators have set these triggers up as invisible DisplayObjects. I imagine we can have them visible but with alpha=0, but a)that would be a bunch of work to change all our resources and b)isn't this a performance issue?

Thanks for any advice.

rawmantick
01-10-2009, 11:39 AM
Objects with visible property set to false take no part in mouse interaction.

But objects with visible property set to true but having only shapes with alpha=0 fill on them do.

So... Don't mix the visual visibilty of objects and their visible property.

Every object with visible property set to false is invisible visually. Bot not every visually invisible object has a visible property set to false;

d000hg
01-10-2009, 11:55 AM
Is there any impact having visible=true, alpha=0 objects? Does Flash actually render the pixels with zero alpha or is it smarter than this?

rawmantick
01-10-2009, 12:10 PM
In-visible objects are not rendered. Visible are rendered, where there is no difference made between different values of alpha. Alpha blending is just made no matter what alpha's value is. And this is not because flash is not smart enough. But because this is how exactly it should be and how it is in every rendering system.

d000hg
01-10-2009, 12:23 PM
OK, thanks. Makes sense although I hoped there might be a flag I could toggle to enable mouse events on visible=false objects. Oh well, that's just how it is :)

rawmantick
01-10-2009, 12:41 PM
Check this (http://www.igorcosta.com/flex3/doc/flash/display/DisplayObject.html#visible) out. It should completely answer your question.

d000hg
01-10-2009, 12:52 PM
I prefer the official version (http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html#visible) but thanks. What is that site anyway?

rawmantick
01-10-2009, 01:32 PM
I don't know... Googled someth...