Mouse events bubble, so the main sprite should still hear it. How are you
attaching your listener?
mainSprite.addEventListener(MouseEvent.MOUSE_DOWN, handleHighlighting );
mainSprite.addEventListener(MouseEvent.ROLL_OVER, handleHighlighting );
mainSprite.addEventListener(MouseEvent.ROLL_OUT, handleHighlighting );
public function handleHighlighting(e:MouseEvent):void
default : break;
So my eventlistner that is to be called on MouseDown shows the event.target as my image and not the mainSprite.
I'm not sure if setting width/height on a loader makes a difference until it
has content, so maybe it has an unexpected size. Check out its
width/height in the mouse event handler.
Sounds like you are in fact getting mouse events even with
Ok, think I have it. I use the code below to add my image to mainSprite. This image is the "loader" that is getting all the mouseEvents. Once I set mouseChildren = false (see last line below) then it works as appropriate. I guess the way I am importanting the images via css (code not shown) somehow underneath the covers is using a loader because I am not explicitly calling or instanciating a loader for this icon image.
_image = new _imgClass();
_image.name = 'icon';
n.data.type == "Cloud" ? _image.scaleX = 0.65 : _image.scaleX = 0.5;
n.data.type == "Cloud" ? _image.scaleY = 0.65 : _image.scaleY = 0.5;
_image.x = -1 * ( (_image.width/2) * _image.scaleX );
_image.y = -1 * ( (_image.height/2) * _image.scaleY );
_image.cacheAsBitmap = true;
n.addChildAt( _image, 0 );
_image.mouseEnabled = false;
_image.mouseChildren = false;
As always, thanks for you help Alex!!!