views:

29

answers:

3

Please, someone could help me?

I need to send the parameter ad_mc by the command:

ad_btn.addEventListener (MouseEvent.MOUSE_MOVE, MouseOver);

to use the same function for all buttons

function MouseOver(evt:MouseEvent):void{
 ad_mc.gotoAndPlay("on");
}

function MouseOut(evt:MouseEvent):void{
 ad_mc.gotoAndPlay("off");
}

ad_btn.addEventListener(MouseEvent.MOUSE_OUT, MouseOut);
ad_btn.addEventListener(MouseEvent.MOUSE_OVER, MouseOver);

If I wanted to send the parameter ad_btn I would use:

MovieClip (evt.target). GotoAndPlay ("on");

but is not the case

A: 

Try using evt.currentTarget

Shiki
A: 

If ad_mc is a child of ad_btn or if ad_mc is listening for mouse events that are bubbling up then you could try using evt.currentTarget otherwise you'll need to do something like this:

function MouseOver(evt:MouseEvent):void
{
    if (evt.target == ad_btn) {
        ad_mc.gotoAndPlay("on");
    }
}

function MouseOut(evt:MouseEvent):void
{
    if (evt.target == ad_btn) {
        ad_mc.gotoAndPlay("off");
    }
}
heavilyinvolved
A: 

at this link you can see the difference between evt.target vs evt.currentTarget: link text

David Verhulst