PDA

View Full Version : mouse interaction w/ the object below a object


dreamflight
12-31-2008, 10:21 AM
let me try to lay this out simply.

suppose i do this:
objectA.addEventListener( MouseEvent.MOUSE_OVER, objAfunction );

and i lay a half transparent rectangle(objectB) over objectA.
what happens now, is the mouseover listener doesn't respond, of course.
but what am i to do, if i want to have objectB over objectA, and still have objectA listen for Mouse Events?

any clues?:confused:

tarafenton
12-31-2008, 03:49 PM
You have to use mouseEnabled = false; for the object on top.
Here's a little example that you can copy and paste to play with the opinions

//////////////
var green:MovieClip = new MovieClip();
green.graphics.beginFill(0x00FF00);
green.graphics.drawRect(100, 100, 500, 75);
addChild(green);

var red:MovieClip = new MovieClip();
red.graphics.beginFill(0xFF0000);
red.graphics.drawRect(300, 50, 300, 300);
red.alpha = .75;
addChild(red);

green.buttonMode = true;
green.mouseEnabled = true;
green.useHandCursor = true;

red.mouseEnabled = false;
// to see the difference remove the comments from the next line
//red.mouseEnabled = true;
red.mouseChildren = true;

green.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);

function mouseOver(e:Event)
{
trace("Event is: " + e);
trace("Event target = " + e.target);
}

//////////////