Question

I have a Image XML menu that works well, but with a litle problem with target in TweenMax. I will post only the code that is relevant to resolve the problem, I hope :D .

I have a MC in library, and inside I have 3 movie clips, img_mc, bg_mc (this is a background for text) and title_mc (inside this mc I have a textfield named title-txt).

I create a for loop for the MC, and I use e.currentTarget in my tween animations.

When I hovered the title_mc is suposed to scale the background, but because bg_mc are in back of the text, the hover don't works. I do not know how to target the title_mc for on MOUSE:OVER scale the bg_mc.

Important Pieces of Code:

for (var i:Number = 0; i < my_total; i++)
   {
      //CREATE THE LOOP FOR MOVIE CLIP THAT I HAVE IN LIBRARY WITH THE CLASS "menu_item"
      var MC:MovieClip = new menu_item();
      MC.id = "i" + i;
      MC.label = my_menu[i]. @ LABEL;
      MC.name = "mc" + i;

Animation Events:

//ANIMATION EVENTS
MC.container_mc.bg_mc.addEventListener(MouseEvent.MOUSE_OVER, hover_bg);
MC.container_mc.bg_mc.addEventListener(MouseEvent.MOUSE_OUT, out_bg);

function hover_bg(e:MouseEvent)
{
   TweenLite.to(e.currentTarget,1,{scaleY:1.2,ease:Quad.easeInOut});
   TweenLite.to(e.currentTarget,1,{alpha:0.8});
}
function out_bg(e:MouseEvent)
{
   TweenLite.to(e.currentTarget,1,{scaleY:1,ease:Quad.easeInOut});
   TweenLite.to(e.currentTarget,1,{alpha:0.6});
}

This Last piece of code don't works because title_mc is over bg_mc.

If I put in event MC.container_mc.title_mc.addEventListener(MouseEvent.MOUSE_OUT, out_bg); the Text will scale too, and I don't want this...

Thanks

Was it helpful?

Solution

Try setting the hitArea property of your MCs to there bg_mc clips. And set the MCs mouseChildren property to false.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top