我是Flash CS5和AS3中的新手,我遇到了问题!我在MovieClip中使用给定的实例名称在舞台上转换了3个矩形。这三个都具有颜色效果的属性:alpha = 50.我在as3层中键入以下代码:
addEventListener(MouseEvent.ROLL_OVER, RollOverBtn);
addEventListener(MouseEvent.ROLL_OUT, RollOutBtn);
function RollOverBtn(event:MouseEvent):void
{
event.target.alpha = 100;
}
function RollOutBtn(event:MouseEvent):void
{
event.target.alpha = 50;
}
问题是,当鼠标滑过一个矩形时,alpha会变为100.但是当鼠标滚出时,没有任何反应!
有什么建议吗?
我已将代码更改为:
btn1.addEventListener(MouseEvent.ROLL_OVER, MouseOverBtn);
btn1.addEventListener(MouseEvent.ROLL_OUT, MouseOutBtn);
btn2.addEventListener(MouseEvent.ROLL_OVER, MouseOverBtn);
btn2.addEventListener(MouseEvent.ROLL_OUT, MouseOutBtn);
btn3.addEventListener(MouseEvent.ROLL_OVER, MouseOverBtn);
btn3.addEventListener(MouseEvent.ROLL_OUT, MouseOutBtn);
function MouseOverBtn(event:MouseEvent):void
{
trace("roll over"+event.target);
event.target.alpha = 1;
}
function MouseOutBtn(event:MouseEvent):void
{
trace("roll out"+event.target);
if(event.target.alpha == 100){
event.target.alpha = 0.5;
}
}
我得到的跟踪消息是:
roll over[object MovieClip]
roll out[object MovieClip]
据我所知,这意味着roll_out已被触发但仍未改变alpha属性。
答案 0 :(得分:1)