我是 Flash CS5 和 AS3 的新手,我有一个问题!我在舞台上有 3 个矩形在具有给定实例名称的 MovieClips 中转换。这三个都具有颜色效果的属性: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 属性。