开发者

Actionscript3 button tip

开发者 https://www.devze.com 2022-12-28 15:29 出处:网络
Please, someone could help me? I need to send the parameter ad_mc by the command: ad_btn.addEventListener (MouseEvent.MOUSE_MOVE, MouseOver);

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

0

精彩评论

暂无评论...
验证码 换一张
取 消