我是动作脚本3的新手,我似乎无法将旧动作脚本转换为最新版本(as3)。当鼠标滚过按钮时,我试图将我的影片剪辑从alpha(透明)设置为可见。这是我的旧代码。
//btnOver is a gaint button over my screen that is transparent
function btnOver(event:MouseEvent):void{
button_overlay._visible = false;
on(rollOver){
minutes_mc._visible = true;
hours_mc._visible = true;
seconds_mc._visible = true;
}
on(rollOut){
minutes_mc._visible = false;
hours_mc._visible = false;
seconds_mc._visible = false;
}
以下是我在AS3中的其余(或整个)代码。
import flash.events.MouseEvent;
var date:Date;
var theDate:Date = new Date( );
var day = theDate.toLocaleDateString()
var time = theDate.toLocaleTimeString()
addEventListener(Event.ENTER_FRAME, refreshHour);
addEventListener(MouseEvent.ROLL_OVER, btnOver);
function refreshHour(event:Event):void{
date = new Date();
hour_mc.rotation = date.getHours()*30 + (date.getMinutes()/2);
hours_mc.rotation = date.getHours()*30 + (date.getMinutes()/2);
minutes_mc.rotation = date.getMinutes()*6 + (date.getSeconds()/10);
minute_mc.rotation = date.getMinutes()*6 + (date.getSeconds()/10);
seconds_mc.rotation = date.getSeconds()*6 + (date.getMilliseconds()/(1000/6));
second_mc.rotation = date.getSeconds()*6 + (date.getMilliseconds()/(1000/6));
}
date_txt.text = day;
//btnOver is a gaint button over my screen that is transparent
function btnOver(event:MouseEvent):void{
button_overlay._visible = false;
on(rollOver){
minutes_mc._visible = true;
hours_mc._visible = true;
seconds_mc._visible = true;
}
on(rollOut){
minutes_mc._visible = false;
hours_mc._visible = false;
seconds_mc._visible = false;
}
基本上我制作的闪光手表在翻滚时发光:)
由于 乔
答案 0 :(得分:2)
const GLOW:GlowFilter = new GlowFilter(0xFF0000);
screen.addEventListener(MouseEvent.ROLL_OVER, _rollOver);
screen.addEventListener(MouseEvent.ROLL_OUT, _rollOut);
function _rollOver(e:Event):void
{
watch.filters = [GLOW];
}
function _rollOut(e:Event):void
{
watch.filters = [];
}
答案 1 :(得分:0)
在这里你要使用两个函数,一个用于over,另一个用于out。例如:
addEventListener(MouseEvent.ROLL_OVER, btnOver);
addEventListener(MouseEvent.ROLL_OUT, btnOut);
function btnOver(event:MouseEvent):void{
// do everything here you want when the mouse goes over
button_overlay._visible = true;
minutes_mc._visible = true;
hours_mc._visible = true;
seconds_mc._visible = true;
}
function btnOut(event:MouseEvent):void{
// do everything here you want when the mouse goes out
button_overlay._visible = false;
minutes_mc._visible = false;
hours_mc._visible = false;
seconds_mc._visible = false;
}