Skip to main content
Known Participant
September 22, 2010
Question

Layered objects and functions

  • September 22, 2010
  • 1 reply
  • 617 views

I have two movie clips on the stage: mcA and mcB, each have a function when rolled over:

mcA.addEventListener(MouseEvent.ROLL_OVER , aActivated);
function aActivated (event:MouseEvent):void
{
     trace('mcA was rolled over');
}

mcB.addEventListener(MouseEvent.ROLL_OVER , bActivated);
function bActivated (event:MouseEvent):void
{
     trace('mcB was rolled over');
}

Under certain circumstances mcA may overlap mcB. When the cursor rolls over their intersecting area I would like both functions to launch, how do I do that? Currently, the problem is that only the object on the top will launch its function.

Thanks for the help.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
September 22, 2010

use a hittestobject for the bottom-most object in your top-most object's rollover listener function.

Known Participant
September 22, 2010

I see where your headed with that, but considering the nature of my objects that will make for a lot of code. I actually just discovered:

if (mouseX > 0 && mouseX < 66 && mouseY > 0 && mouseY < 110)
{
     trace('rolled over');
}

puting this code on the timeline of the bottom MC seems to work pretty well for what I need.