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 开发者_StackOverflow中文版(evt.target). GotoAndPlay ("on");
but is not the case
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");
}
}
Try using evt.currentTarget
精彩评论